This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/47418] warning: array subscript is above array bounds at O2 with sin6_addr


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47418

--- Comment #3 from Xavier <chantry.xavier at gmail dot com> 2011-01-23 02:06:35 UTC ---
Created attachment 23084
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23084
simpler testcase

$ gcc -O3 -Wall -c small-test.c 
small-test.c: In function 'main':
small-test.c:18:51: warning: array subscript is above array bounds
small-test.c:18:43: warning: array subscript is above array bounds
small-test.c:18:35: warning: array subscript is above array bounds

so gcc seems to think that the size of ap is 13 instead of 16.
It's important that ap and sa_data are both char, and u6_addr8 is unsigned
char.
Same warning if ap and sa_data are unsigned char and u6_addr8 is char.
But other combinations apparently do not give any warning.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]