http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44871

--- Comment #13 from Richard Guenther <rguenth at gcc dot gnu.org> 2010-11-26 
17:06:25 UTC ---
Testcase:

> cat gcc/testsuite/g++.dg/lto/20101126-1_0.C
typedef struct { int i; } T1;
typedef T1 T2;
extern T1 a;
extern T2 b;
int main() { return a.i + b.i; }

> cat gcc/testsuite/g++.dg/lto/20101126-1_1.c
typedef struct { int i; } T1;
typedef T1 T2;
T1 a;
T2 b;

/space/rguenther/src/svn/trunk/gcc/testsuite/g++.dg/lto/20101126-1_0.C:3:11:
warning: type of 'a' does not match original declaration [enabled by default]^M
/space/rguenther/src/svn/trunk/gcc/testsuite/g++.dg/lto/20101126-1_1.c:3:4:
note: previously declared here^M
/space/rguenther/src/svn/trunk/gcc/testsuite/g++.dg/lto/20101126-1_0.C:4:11:
warning: type of 'b' does not match original declaration [enabled by default]^M
/space/rguenther/src/svn/trunk/gcc/testsuite/g++.dg/lto/20101126-1_1.c:4:4:
note: previously declared here^M

(gdb) call debug_tree (prevailing->decl)
 <var_decl 0x7ffff5d071e0 a
    type <record_type 0x7ffff5d083f0 T1 SI
        size <integer_cst 0x7ffff7ed36e0 constant 32>
        unit size <integer_cst 0x7ffff7ed33e8 constant 4>
        align 32 symtab 0 alias set -1 structural equality
        fields <field_decl 0x7ffff7edbda8 i type <integer_type 0x7ffff7ee3498>
            nonlocal SI file t4.ii line 1 col 22 size <integer_cst
0x7ffff7ed36e0 32> unit size <integer_cst 0x7ffff7ed33e8 4>
            align 32 offset_align 128
            offset <integer_cst 0x7ffff7ed3410 constant 0>
            bit offset <integer_cst 0x7ffff7ed3b18 constant 0> context
<record_type 0x7ffff5d083f0 T1>>>
    public static SI file t4.ii line 3 col 4 size <integer_cst 0x7ffff7ed36e0
32> unit size <integer_cst 0x7ffff7ed33e8 4>
    align 32 context <translation_unit_decl 0x7ffff7edde60 D.2010>>
(gdb) call debug_tree (decl)
 <var_decl 0x7ffff5d07000 a
    type <record_type 0x7ffff5d080a8 SI
        size <integer_cst 0x7ffff7ed36e0 constant 32>
        unit size <integer_cst 0x7ffff7ed33e8 constant 4>
        align 32 symtab 0 alias set -1 structural equality
        fields <field_decl 0x7ffff7edbd10 i type <integer_type 0x7ffff7ee3498>
            SI file t3.i line 1 col 22 size <integer_cst 0x7ffff7ed36e0 32>
unit size <integer_cst 0x7ffff7ed33e8 4>
            align 32 offset_align 128
            offset <integer_cst 0x7ffff7ed3410 constant 0>
            bit offset <integer_cst 0x7ffff7ed3b18 constant 0> context
<record_type 0x7ffff5d080a8>>>
    used public external common SI file t3.i line 3 col 11 size <integer_cst
0x7ffff7ed36e0 32> unit size <integer_cst 0x7ffff7ed33e8 4>
    align 32 context <translation_unit_decl 0x7ffff7eddb80 D.2001>>


if we want to have the same canonical type for the above we can simply
disregard all names, which makes sense for canonical type merging, but
that makes the hash functions very weak again (we share the type hashes
for type and canonical type merging).  It also can run foul of too much
merging when facing incomplete types which can happen in various places.

Reply via email to