loongson-community / gcc

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

[c-decl, c-typeck] ICE with _Generic selection on _Atomic int #9

Closed xiangzhai closed 6 years ago

xiangzhai commented 6 years ago

Hi @heiher

As PR65345 mentioned: Testcase:

$cat test.c
_Atomic int i;  
int j = _Generic( i+1, int: 1, default: 0 );

Segfault is still reproducible for GCC 5.5:

$  /opt/loongson-gnu-5.5/bin/mips64-linux-gnu-gcc -S test.c
test.c:2:1: internal compiler error: Segmentation fault
 int j = _Generic( i+1, int: 1, default: 0 );
 ^
0x8d38af crash_signal
        ../../gcc/toplev.c:381
0x6d1d80 gimple_body(tree_node*)
        ../../gcc/gimple-expr.c:327
0x720d77 gimple_add_tmp_var(tree_node*)
        ../../gcc/gimplify.c:725
0x6d21bd create_tmp_var(tree_node*, char const*)
        ../../gcc/gimple-expr.c:527
0x511e6a convert_lvalue_to_rvalue(unsigned int, c_expr, bool, bool)
        ../../gcc/c/c-typeck.c:2042
0x52381d c_parser_binary_expression
        ../../gcc/c/c-parser.c:6385
0x523d45 c_parser_conditional_expression
        ../../gcc/c/c-parser.c:6037
0x524190 c_parser_expr_no_commas
        ../../gcc/c/c-parser.c:5955
0x5208aa c_parser_generic_selection
        ../../gcc/c/c-parser.c:6862
0x5208aa c_parser_postfix_expression
        ../../gcc/c/c-parser.c:7671
0x522402 c_parser_unary_expression
        ../../gcc/c/c-parser.c:6608
0x522fcf c_parser_cast_expression
        ../../gcc/c/c-parser.c:6446
0x5231b2 c_parser_binary_expression
        ../../gcc/c/c-parser.c:6261
0x523d45 c_parser_conditional_expression
        ../../gcc/c/c-parser.c:6037
0x524190 c_parser_expr_no_commas
        ../../gcc/c/c-parser.c:5955
0x52d3d9 c_parser_initializer
        ../../gcc/c/c-parser.c:4168
0x51cbc9 c_parser_declaration_or_fndef
        ../../gcc/c/c-parser.c:1825
0x531ebf c_parser_external_declaration
        ../../gcc/c/c-parser.c:1453
0x5328c9 c_parser_translation_unit
        ../../gcc/c/c-parser.c:1340
0x5328c9 c_parse_file()
        ../../gcc/c/c-parser.c:15466
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.

Marek fixed the bug for GCC 5.1 and I migrated to GCC 5.5, please review my migrate, thanks a lot!

Regards, Leslie Zhai

heiher commented 6 years ago

Landed: https://github.com/loongson-community/gcc/commit/491249982f21e8a9487af223cd7f213cf46e3e55 https://github.com/loongson-community/gcc/commit/7a0b3590557ecb8cf40a92eed0e99222b2fad7a1