This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
LTO vs zero length bit fields
- From: Jay Foad <jay dot foad at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Cc: Jan Hubicka <hubicka at ucw dot cz>
- Date: Wed, 2 Mar 2016 16:05:17 +0000
- Subject: LTO vs zero length bit fields
- Authentication-results: sourceware.org; auth=none
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.