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/36902] New: [4.3/4.4 Regression]: Bogus array bound warning


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


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