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 go/86343] New: types built by GO share TYPE_FIELDS in unsupported way


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

            Bug ID: 86343
           Summary: types built by GO share TYPE_FIELDS in unsupported way
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: go
          Assignee: ian at airs dot com
          Reporter: rguenth at gcc dot gnu.org
                CC: cmang at google dot com
  Target Milestone: ---

If you apply

Index: gcc/tree.c
===================================================================
--- gcc/tree.c  (revision 262215)
+++ gcc/tree.c  (working copy)
@@ -13878,6 +13878,16 @@ verify_type (const_tree t)
              debug_tree (fld);
              error_found = true;
            }
+         if (DECL_CONTEXT (fld) != TYPE_MAIN_VARIANT (t)
+             /* class scope enums have their CONST_DECLs in the class
+                TYPE_FIELDS chain in C++.  */
+             && (TREE_CODE (fld) != CONST_DECL
+                 || TREE_CODE (DECL_CONTEXT (fld)) != ENUMERAL_TYPE))
+           {
+             error ("Wrong DECL_CONTEXT in TYPE_FIELDS list");
+             debug_tree (fld);
+             error_found = true;
+           }
        }
     }
   else if (TREE_CODE (t) == INTEGER_TYPE

then you'll hit an ICE building libgo/go/errors/errors.go on x86_64-linux:

go1: error: Wrong DECL_CONTEXT in TYPE_FIELDS list
 <field_decl 0x7f9e5055b098 _type
    type <record_type 0x7f9e50557d20 _type BLK
        size <integer_cst 0x7f9e505426f0 constant 576>
        unit-size <integer_cst 0x7f9e50542768 constant 72>
...
go1: internal compiler error: verify_type failed
0xf71582 verify_type(tree_node const*)
        /space/rguenther/src/svn/trunk/gcc/tree.c:13982
0x98fa94 gen_type_die_with_usage
        /space/rguenther/src/svn/trunk/gcc/dwarf2out.c:25389

where

(gdb) p (void)debug_tree (type)
 <record_type 0x7ffff67d67e0 BLK
    size <integer_cst 0x7ffff67be8e8 type <integer_type 0x7ffff67b60a8
bitsizetype> constant 768>
    unit-size <integer_cst 0x7ffff67be870 type <integer_type 0x7ffff67b6000
sizetype> constant 96>
    align:64 warn_if_not_align:0 symtab:0 alias-set -1 structural-equality
    fields <field_decl 0x7ffff67d7098 _type
        type <record_type 0x7ffff67d3d20 _type BLK
            size <integer_cst 0x7ffff67be6f0 constant 576>
            unit-size <integer_cst 0x7ffff67be768 constant 72>
            align:64 warn_if_not_align:0 symtab:0 alias-set -1
structural-equality fields <field_decl 0x7ffff67d4be0 size>
            pointer_to_this <pointer_type 0x7ffff67d9c78>>
        BLK <built-in>:0:0 size <integer_cst 0x7ffff67be6f0 576> unit-size
<integer_cst 0x7ffff67be768 72>
        align:64 warn_if_not_align:0 offset_align 128
        offset <integer_cst 0x7ffff67a2c18 constant 0>
        bit-offset <integer_cst 0x7ffff67a2c60 constant 0> context <record_type
0x7ffff67d65e8 StructType>

and

(gdb) p ((tree)0x7ffff67d65e8)->type_common.main_variant 
$3 = (tree) 0x7ffff67d65e8
(gdb) p ((tree)0x7ffff67d67e0)->type_common.main_variant 
$4 = (tree) 0x7ffff67d67e0

the type looks like

struct 
{
  struct  _type;
  struct 
  {
    struct  * __values;
    int __count;
    int __capacity;
  } fields;
}

but otherwise is anonymous so it's hard to tell where it originates.

I'm hoping to push this verification to trunk but it fails to bootstrap
with GO.

Basically TYPE_FIELDS (and thus FIELD_DECL) sharing is only valid
between a types variants (thus types sharing the same TYPE_MAIN_VARIANT)
where they are actually expected to be shared.

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