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

            Bug ID: 98200
           Summary: [GIMPLE FE] ICE with parsing ternary expr with
                    -fgimple
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: prathamesh3492 at gcc dot gnu.org
  Target Milestone: ---

Following test-case ICE's with -fgimple:

int __GIMPLE() f(int x, int y)
{
  int a;
  a = (x < y) ? 1 : 2;
  return a;
}


foo.c: In function ‘f’:
foo.c:4:7: error: expected expression before ‘(’ token
    4 |   a = (x < y) ? 1 : 2;
      |       ^
foo.c:4:7: internal compiler error: in extract_ops_from_tree, at
gimple-expr.c:556
0x6a1b64 extract_ops_from_tree(tree_node*, tree_code*, tree_node**,
tree_node**, tree_node**)
        ../../gcc/gcc/gimple-expr.c:556
0xb9ab20 gimple_build_assign(tree_node*, tree_node*)
        ../../gcc/gcc/gimple.c:436
0x91788a c_parser_gimple_statement
        ../../gcc/gcc/c/gimple-parser.c:879
0x91788a c_parser_gimple_compound_statement
        ../../gcc/gcc/c/gimple-parser.c:649
0x91788a c_parser_gimple_compound_statement
        ../../gcc/gcc/c/gimple-parser.c:381
0x919b77 c_parser_parse_gimple_body(c_parser*, char*, c_declspec_il,
profile_count)
        ../../gcc/gcc/c/gimple-parser.c:253
0x908e77 c_parser_declaration_or_fndef
        ../../gcc/gcc/c/c-parser.c:2533
0x9106b3 c_parser_external_declaration
        ../../gcc/gcc/c/c-parser.c:1777
0x911119 c_parser_translation_unit
        ../../gcc/gcc/c/c-parser.c:1650
0x911119 c_parse_file()
        ../../gcc/gcc/c/c-parser.c:21877
0x970de5 c_common_parse_file()
        ../../gcc/gcc/c-family/c-opts.c:1211

The ICE does not happen with parens around x < y are removed.
I guess even if this isn't syntactically valid input to gimple-fe,
it shouldn't ICE during parsing ?

Thanks,
Prathamesh

Reply via email to