LTO vs zero length bit fields

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux