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

            Bug ID: 105232
           Summary: ICE in tree_to_poly_int64, at tree.cc:3224
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: k.even-mendoza at imperial dot ac.uk
  Target Milestone: ---

The following code crashed gcc-12 with all flags, and gcc-11 with -O1, -O2, -O3
and -Os but works fine with -O0. gcc-10 and below works fine.

===
c;
#define d(expr, e)                                                            
\
  char *f = expr;                                                             
\
  strlen(f) ?: ++c;
struct {
  char a[0], b[1537228674000000000]
} cma[] = {{}, {}, {}, {}, {}, {}};
g() { d(cma[4].a, ) }
===

crashed with:
/home/user42/data/gcc-csmith-1201/gcc-install/bin/gcc -O2 fuzzer-file-3200.c
...
fuzzer-file-3200-1.c:8:7: note: in expansion of macro ‘d’
    8 | g() { d(cma[4].a, ) }
      |       ^
during GIMPLE pass: waccess
fuzzer-file-3200-1.c:8:1: internal compiler error: in tree_to_poly_int64, at
tree.cc:3224
    8 | g() { d(cma[4].a, ) }
      | ^
0x7e75cb tree_to_poly_int64(tree_node const*)
        .././../gcc-source/gcc/tree.cc:3224
0x7e75cb tree_to_poly_int64(tree_node const*)
        .././../gcc-source/gcc/tree.cc:3222
...
0xc0ffb8 check_builtin
        .././../gcc-source/gcc/gimple-ssa-warn-access.cc:3181
0xc0ffb8 check_call
        .././../gcc-source/gcc/gimple-ssa-warn-access.cc:4280
0xc0ffb8 check_block
        .././../gcc-source/gcc/gimple-ssa-warn-access.cc:4393
0xc0ffb8 execute
        .././../gcc-source/gcc/gimple-ssa-warn-access.cc:4742

===========================
With -O0 it ends without crashing and prints the right error:
gcc-11 -O0 fuzzer-file-3200.c
...
fuzzer-file-3200.c:8:7: note: in expansion of macro ‘d’
    8 | g() { d(cma[4].a, ) }
      |       ^
fuzzer-file-3200.c: At top level:
fuzzer-file-3200.c:7:3: error: size of variable ‘cma’ is too large
    7 | } cma[] = {{}, {}, {}, {}, {}, {}};

Reply via email to