I have tried this with both gcc 3.3.5 and 3.4.4:

gcc-3.4 (GCC) 3.4.4 20041218 (prerelease) (Debian 3.4.3-6)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

gcc (GCC) 3.3.5 (Debian 1:3.3.5-5)
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Here is code:

struct thing {
    unsigned char *ptr;
};

struct thing array[1] = {
    { .ptr = ((unsigned char []) { 0x1, 0x2 }) }
};

And the warnings I don't think I should be getting:

[EMAIL PROTECTED] gcc-3.4 -c test.c 
test.c:9: warning: excess elements in array initializer
test.c:9: warning: (near initialization for `(anonymous)')


If i change array[1] to array[2] then I recieve no warnings.
It seems as if the outside array size is being used to check the internal
array constructor thinggy.

-- 
           Summary: spurious warnings with nested array constructors
           Product: gcc
           Version: 3.4.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rfeany at mrv dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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

Reply via email to