This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

LTO vs zero length bit fields


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]