https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78472
Bug ID: 78472 Summary: warning: type of 's' does not match original declaration from zero length bitfield in C vs C++ Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto Assignee: unassigned at gcc dot gnu.org Reporter: jay.foad at gmail dot com Target Milestone: --- If I compile x.h as C and as C++, and link the two together with LTO, I get this warning, which seems spurious to me: x.h:5:3: warning: type of 's' does not match original declaration Here's the repro: $ cat x.h extern struct S { unsigned i:4; unsigned :0; } s; static void *f(void) { return &s; } $ gcc -o /dev/null -flto -x c x.h -x c++ x.h x.h:5:3: warning: type of 's' does not match original declaration [-Wlto-type-mismatch] } s; ^ x.h:5:3: note: type 'struct S' should match type 'struct S' } s; ^ x.h:1:15: note: the incompatible type is defined here extern struct S ^ x.h:5:3: note: 's' was previously declared here } s; ^ x.h:5:3: note: code may be misoptimized unless -fno-strict-aliasing is used $ gcc -v Using built-in specs. COLLECT_GCC=/home/jay/gcc/local/bin/gcc COLLECT_LTO_WRAPPER=/home/jay/gcc/local/libexec/gcc/x86_64-pc-linux-gnu/7.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /home/jay/svn/gcc/trunk/configure --prefix=/home/jay/gcc/local --disable-bootstrap --enable-languages=c,c++,lto Thread model: posix gcc version 7.0.0 20161122 (experimental) (GCC) I built this compiler from source at svn r242695.