https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60784

Christian Bauer <cb at cebix dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |cb at cebix dot net

--- Comment #9 from Christian Bauer <cb at cebix dot net> ---
There still appears to be a problem here, even with GCC 6.2.1 (gcc-6 (SUSE
Linux) 6.2.1 20160826 on x86_64):

//////////////////////////////////////////
gcc -Wextra warn.c -o /dev/null
//////////////////////////////////////////
struct foo {
    char x;
    struct {
        char a;
        char b;
    };
};

int main(void) {
    struct foo test[1] = {
        [0].x = 1,
        [0].a = 2,
        [0].b = 3,
    };

    return test[0].a == 2;
}
///////////////////////////////////////////

Output:
warn.c: In function ‘main’:
warn.c:12:9: warning: missing initializer for field ‘({anonymous})’ of ‘struct
foo’ [-Wmissing-field-initializers]
         [0].a = 2,
         ^
warn.c:6:5: note: ‘({anonymous})’ declared here
     };

Interestingly, changing "[0].x = 1" to "[0].x = 0" makes the warning disappear.

Reply via email to