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

            Bug ID: 109598
           Summary: ICE: tree check: expected array_type, have error_mark
                    in array_ref_low_bound, at tree.cc
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: anbu1024.me at gmail dot com
  Target Milestone: ---

gcc (GCC) 13.0.1 20230219 snapshot ICEs when compiling the following testcase

$ gcc --version
gcc (GCC) 13.0.1 20230219 (experimental)
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

--------------------------------

$ cat 2.c

extern char g[];

char *foo(void)
{
  return &g[0];
}

char *g(void)
{
  return &g[1];
}

--------------------------------

$ gcc 2.c 
2.c:9:7: error: ‘g’ redeclared as different kind of symbol
    9 | char *g(void)
      |       ^
2.c:2:13: note: previous declaration of ‘g’ with type ‘char[]’
    2 | extern char g[];
      |             ^
2.c: In function ‘g’:
2.c:11:12: error: subscripted value is neither array nor pointer nor vector
   11 |   return &g[1];
      |            ^
2.c: In function ‘foo’:
2.c:6:12: internal compiler error: tree check: expected array_type, have
error_mark in array_ref_low_bound, at tree.cc:12782
    6 |   return &g[0];
      |           ~^~~
0x840178 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ../../gcc-13-20230219/gcc/tree.cc:8909
0x8499ae tree_check(tree_node*, char const*, int, char const*, tree_code)
        ../../gcc-13-20230219/gcc/tree.h:3530
0x8499ae array_ref_low_bound(tree_node*)
        ../../gcc-13-20230219/gcc/tree.cc:12782
0xc8caf9 gimplify_compound_lval
        ../../gcc-13-20230219/gcc/gimplify.cc:3219
0xc875fe gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc-13-20230219/gcc/gimplify.cc:16313
0xc8e602 gimplify_addr_expr
        ../../gcc-13-20230219/gcc/gimplify.cc:6561
0xc8805d gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc-13-20230219/gcc/gimplify.cc:16408
0xc9a465 gimplify_modify_expr
        ../../gcc-13-20230219/gcc/gimplify.cc:6153
0xc879e1 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc-13-20230219/gcc/gimplify.cc:16361
0xc8a316 gimplify_stmt(tree_node**, gimple**)
        ../../gcc-13-20230219/gcc/gimplify.cc:7219
0xc96670 gimplify_and_add(tree_node*, gimple**)
        ../../gcc-13-20230219/gcc/gimplify.cc:492
0xc96670 gimplify_return_expr
        ../../gcc-13-20230219/gcc/gimplify.cc:1680
0xc87d0a gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc-13-20230219/gcc/gimplify.cc:16623
0xc8a316 gimplify_stmt(tree_node**, gimple**)
        ../../gcc-13-20230219/gcc/gimplify.cc:7219
0xc8aa47 gimplify_bind_expr
        ../../gcc-13-20230219/gcc/gimplify.cc:1430
0xc87c95 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc-13-20230219/gcc/gimplify.cc:16562
0xca912e gimplify_stmt(tree_node**, gimple**)
        ../../gcc-13-20230219/gcc/gimplify.cc:7219
0xca912e gimplify_body(tree_node*, bool)
        ../../gcc-13-20230219/gcc/gimplify.cc:17623
0xca958a gimplify_function_tree(tree_node*)
        ../../gcc-13-20230219/gcc/gimplify.cc:17822
0xad7fa7 cgraph_node::analyze()
        ../../gcc-13-20230219/gcc/cgraphunit.cc:676
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

Reply via email to