On Linux/x86-64, gcc 4.3/4.4 give: [EMAIL PROTECTED] gcc]$ cat /tmp/y.c /* * compile w/: * gcc -Wall -Werror -fno-strict-aliasing -O2 -c foo.c */
typedef unsigned char __u8; typedef unsigned short __u16; static inline void * foo( void * to, const void * from, int n) { switch ( n ) { case 3: *(__u16 *)to = *(const __u16 *)from; break; case 5: *((__u8 *)to + 4) = *((const __u8 *)from + 4); break; } return to; } int main(int argc, char *argv[]) { static char buf[64]; struct { __u16 size_of_select; __u8 pcr_select[4]; } sel; sel.size_of_select = 3; foo(buf, sel.pcr_select, sel.size_of_select); return 1; } [EMAIL PROTECTED] gcc]$ ./xgcc -B./ -Wall -Werror -fno-strict-aliasing -O2 -c /tmp/y.c cc1: warnings being treated as errors /tmp/y.c: In function âmainâ: /tmp/y.c:18: error: array subscript is above array bounds [EMAIL PROTECTED] gcc]$ Gcc 4.1 is OK. -- Summary: [4.3/4.4 Regression]: Bogus array bound warning Product: gcc Version: 4.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: hjl dot tools at gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36902