FYI I've reported it here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78472 On 2 March 2016 at 16:05, Jay Foad <jay.foad@xxxxxxxxx> wrote: > Hi, > > I'm trying to use LTO to build a large C/C++ application, and I'm > getting some warnings that I don't understand: > > warning: type of ‘s’ does not match original declaration > > Here's a reduced test case: > > $ cat common.h > extern struct S > { > unsigned i:4; > unsigned :0; > } s; > static void *f(void) > { > return &s; > } > > $ cat c.c > #include "common.h" > > $ cat cpp.cpp > #include "common.h" > > $ gcc -o /dev/null -flto c.c cpp.cpp > common.h:5:3: warning: type of ‘s’ does not match original declaration > } s; > ^ > common.h:5:3: note: previously declared here > } s; > ^ > > It looks like the zero-length bitfield is causing a problem, and > somehow makes the structure incompatible in C vs C++. Why? Is there a > better fix than just not using zero-length bitfields? > > I'm using GCC 5.2.1 on Ubuntu 15.10, but I get the same warning if I > use a GCC 6 built from trunk sources about a week ago. > > Thanks, > Jay.