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

            Bug ID: 122982
           Summary: ICE in in gimplify_expr, at gimplify.cc:21136 when
                    counted_by for pointer is added
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: qinzhao at gcc dot gnu.org
  Target Milestone: ---

with the following small testing case, the latest GCC failed:
[]$ cat t1.c
int* f (int);

struct __bounded_ptr {
 int k;
 int *buf __attribute__ ((counted_by (k)));
};

int*
f1 (int n) { return f (n); }

void h1 (void)
{ 
  int *p = (struct __bounded_ptr) {3, f1 (3)}.buf;
  __builtin_memset (p, 0, 3 * sizeof p);   // missing warning
}
[]$ gcc t1.c
t1.c: In function ‘h1’:
t1.c:13:12: internal compiler error: in gimplify_expr, at gimplify.cc:21136
   13 |   int *p = (struct __bounded_ptr) {3, f1 (3)}.buf;
      |            ^
0x2279fbb internal_error(char const*, ...)
        ../../latest-gcc-write/gcc/diagnostic-global-context.cc:534
0x843137 fancy_abort(char const*, int, char const*)
        ../../latest-gcc-write/gcc/diagnostics/context.cc:1687
0xcebaaf gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../latest-gcc-write/gcc/gimplify.cc:21136
0xcf729b gimplify_compound_lval
        ../../latest-gcc-write/gcc/gimplify.cc:3578
0xcebf93 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../latest-gcc-write/gcc/gimplify.cc:20230
0xd077d3 gimplify_expr
        ../../latest-gcc-write/gcc/gimplify.cc:21390
0xd077d3 gimplify_arg(tree_node**, gimple**, unsigned long, bool)
        ../../latest-gcc-write/gcc/gimplify.cc:3839
0xd16217 gimplify_modify_expr
        ../../latest-gcc-write/gcc/gimplify.cc:7465
0xcec403 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../latest-gcc-write/gcc/gimplify.cc:20281
0xcef05b gimplify_stmt(tree_node**, gimple**)
        ../../latest-gcc-write/gcc/gimplify.cc:8572
0xd0a203 gimplify_and_add(tree_node*, gimple**)
        ../../latest-gcc-write/gcc/gimplify.cc:554
0xd0a203 gimplify_decl_expr
        ../../latest-gcc-write/gcc/gimplify.cc:2209
0xcecb17 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../latest-gcc-write/gcc/gimplify.cc:20478
0xcef05b gimplify_stmt(tree_node**, gimple**)
        ../../latest-gcc-write/gcc/gimplify.cc:8572
0xced497 gimplify_statement_list
        ../../latest-gcc-write/gcc/gimplify.cc:2292
0xced497 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../latest-gcc-write/gcc/gimplify.cc:20732
0xcef05b gimplify_stmt(tree_node**, gimple**)
        ../../latest-gcc-write/gcc/gimplify.cc:8572
0xceff0f gimplify_bind_expr
        ../../latest-gcc-write/gcc/gimplify.cc:1687
0xcec8af gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../latest-gcc-write/gcc/gimplify.cc:20482
0xd195a7 gimplify_stmt(tree_node**, gimple**)
        ../../latest-gcc-write/gcc/gimplify.cc:8572
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.

deleting the counted_by attribute from the source code resolves the ICE.

Reply via email to