This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/47418] warning: array subscript is above array bounds at O2 with sin6_addr
- From: "chantry.xavier at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 23 Jan 2011 02:06:39 +0000
- Subject: [Bug c/47418] warning: array subscript is above array bounds at O2 with sin6_addr
- Auto-submitted: auto-generated
- References: <bug-47418-4@http.gcc.gnu.org/bugzilla/>
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.