This is the mail archive of the gcc-bugs@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]

[Bug lto/78472] warning: type of 's' does not match original declaration from zero length bitfield in C vs C++


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78472

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |lto, wrong-code
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2016-11-22
                 CC|                            |hubicka at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  The C variant has a FIELD_DECL for the :0 while the C++ variant
does not have that.  This makes them not share a canonical type.

Thus this is a possible wrong-code C/C++ interoperability issue.

(gdb) p debug_tree ((tree)0x7ffff6a6c1c8)
 <field_decl 0x7ffff6a6c1c8 D.3900
    type <integer_type 0x7ffff6a6dc78 unsigned QI
        size <integer_cst 0x7ffff6887ca8 constant 8>
        unit size <integer_cst 0x7ffff6887cc0 constant 1>
        align 8 symtab 0 alias set -1 canonical type 0x7ffff6a6dc78 precision
0>
    unsigned external bit-field nonaddressable QI file x.h line 4 col 1
    size <integer_cst 0x7ffff6887c30 type <integer_type 0x7ffff688b2a0
bitsizetype> constant 0>
    unit size <integer_cst 0x7ffff6887be8 type <integer_type 0x7ffff688b1f8
sizetype> constant 0>
    align 32 offset_align 128 offset <integer_cst 0x7ffff6887be8 0>

so the field has zero size.  Ignoring zero-sized fields in canonical type
hashing/comparing works.  Testing a patch.

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