------- Comment #12 from hjl dot tools at gmail dot com 2008-07-23 01:23 ------- (In reply to comment #11) > Thanks. Actually, I think the experiment would be more meaningful if you could > put also the equivalent of your main (a calling function, that is) inside the > header, because in your testcase the warning is triggered inside the main, not > in foo. >
Same: [EMAIL PROTECTED] tmp]$ cat y.h #pragma GCC system_header static inline unsigned char * foo(unsigned char * to, const unsigned char * from, int n) { switch ( n ) { case 3: *to = *from; break; case 5: to[4] = from [4]; break; } return to; } struct { int size_of_select; unsigned char pcr_select[4]; } sel; static int bar (void) { static unsigned char buf[64]; sel.size_of_select = 3; foo(buf, sel.pcr_select, sel.size_of_select); return 1; } [EMAIL PROTECTED] tmp]$ cat y.c #include <y.h> int main () { return bar (); } [EMAIL PROTECTED] tmp]$ gcc -Wall -O2 -c y.c -Werror -I. cc1: warnings being treated as errors y.c: In function âmainâ: ./y.h:11: error: array subscript is above array bounds [EMAIL PROTECTED] tmp]$ -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36902