This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/36902] New: [4.3/4.4 Regression]: Bogus array bound warning
- From: "hjl dot tools at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 Jul 2008 18:43:44 -0000
- Subject: [Bug c/36902] New: [4.3/4.4 Regression]: Bogus array bound warning
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
On Linux/x86-64, gcc 4.3/4.4 give:
[hjl@gnu-6 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;
}
[hjl@gnu-6 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
[hjl@gnu-6 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