------- Comment #23 from falk at debian dot org 2006-02-18 12:58 ------- (In reply to comment #21) > hmm, thanks. it should have looked like this: > > + case TRY_FINALLY_EXPR: > + case TRY_CATCH_EXPR: > + array_offset_warning (&TREE_OPERAND (t, 0)); > + array_offset_warning (&TREE_OPERAND (t, 1)); > + break; > + case CATCH_EXPR: > + array_offset_warning (&CATCH_BODY (t)); > + break; > > Anyway, I agree that the SSA pass after all const folding has happened is a > much better approach than my quick hack, as long as it isn't significantly > slower (compile time). I'm currently trying Falk's patch.
The problem it had was with inlining: code like static inline int f(int a[], int b) { return a[b]; // line 2 } int g(void) { int a[2] = {1, 2}; return f(a, 2); // line 7 } To really be helpful, the warning should say something like "array access out of bound in line 2 after inlining in line 7", but I don't know how to achieve that. The "uninitialized" warning has the same problem by running so late; it punts and just says "a used uninitialized in g", which seems kinda lame. Anyway, the warning is probably still useful if this is not resolved... -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8268