http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60784
Bug ID: 60784 Summary: Spurious -Wmissing-field-initializers warning for anonymous structure Product: gcc Version: 4.8.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: peter at lekensteyn dot nl When an anonymous structure gets initialized, gcc always starts complaining about the last field: ////////////////////////////////////////// gcc -Wextra warn.c -o /dev/null ////////////////////////////////////////// struct foo { struct { char a; char b; }; }; int main(void) { struct foo test = { .a = 1, .b = 2, }; return test.a == 1; } /////////////////////////////////////////// Output: warn.c: In function ‘main’: warn.c:12:9: warning: missing initializer for field ‘b’ of ‘struct <anonymous>’ [-Wmissing-field-initializers] .b = 2, ^ warn.c:5:14: note: ‘b’ declared here char b; ^ It gets even worse when adding more fields. For fun, add "char c;" between "char a;" and "char b;". The first warning mentions "c", but the line thereafter points to "b": warn.c: In function ‘main’: warn.c:13:9: warning: missing initializer for field ‘c’ of ‘struct <anonymous>’ [-Wmissing-field-initializers] .b = 2, ^ warn.c:5:14: note: ‘c’ declared here char c; ^ Expected result: no warnings for the first case. This is gcc-multilib 4.8.2-8 on Arch Linux x86_64. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: /build/gcc-multilib/src/gcc-4.8-20140206/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-cloog-backend=isl --disable-cloog-version-check --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-multilib --disable-werror --enable-checking=release Thread model: posix gcc version 4.8.2 20140206 (prerelease) (GCC)