loongson-community / gcc

GCC source tree for Loongson
GNU General Public License v2.0
17 stars 1 forks source link

[cp/class] ICE on invalid reference type in union #25

Open xiangzhai opened 6 years ago

xiangzhai commented 6 years ago

Hi fellows,

As PR78890 mentioned: Testcase:

int main() {
  union {
    int a;
    int &b = a;
  };
  a = 1;
  auto c = b + 1;
}

Segfault for GCC 6-branch is reproducible:

$ /opt/loongson-gnu-6/bin/mips64-linux-gnu-g++ -c t.ii
t.ii: In function ‘int main()’:
t.ii:7:12: internal compiler error: Segmentation fault
   auto c = b + 1;
            ^
0xa7f02f crash_signal
        ../../gcc/toplev.c:333
0x811b30 expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool)
        ../../gcc/expr.c:9971
0x821167 expand_expr
        ../../gcc/expr.h:260
0x821167 expand_expr_real_2(separate_ops*, rtx_def*, machine_mode, expand_modifier)
        ../../gcc/expr.c:8185
0x8124b7 expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool)
        ../../gcc/expr.c:10925
0x81b87f expand_expr
        ../../gcc/expr.h:260
0x81b87f store_expr_with_bounds(tree_node*, rtx_def*, int, bool, bool, tree_node*)
        ../../gcc/expr.c:5314
0x81c3ff expand_assignment(tree_node*, tree_node*, bool)
        ../../gcc/expr.c:5176
0x73c0ee expand_gimple_stmt_1
        ../../gcc/cfgexpand.c:3618
0x73c0ee expand_gimple_stmt
        ../../gcc/cfgexpand.c:3714
0x73dcd5 expand_gimple_basic_block
        ../../gcc/cfgexpand.c:5720
0x7429b6 execute
        ../../gcc/cfgexpand.c:6335
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://github.com/loongson-community/gcc/issues> for instructions.

Not effect gcc 5.5, 7-branch or 8.x master. Regards, Leslie Zhai