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

            Bug ID: 101172
           Summary: [12 regression] ICE Segmentation fault
           Product: gcc
           Version: 12.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: ---

$ cat 36.c 

union U
{
  int a[3];
  struct
  {
    int a : 3;
    struct this_struct var;
  } b;
};

const union U hello = {.a = {1, 2, 3}};


void foo()
{
  int x = hello.b.a;
}

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

$ gcc-sp12 --version
gcc (GCC) 12.0.0 20210620 (experimental)
Copyright (C) 2021 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.

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

$ gcc-sp12 36.c 
36.c:8:24: error: field ‘var’ has incomplete type
    8 |     struct this_struct var;
      |                        ^~~
36.c: In function ‘foo’:
36.c:17:18: internal compiler error: Segmentation fault
   17 |   int x = hello.b.a;
      |           ~~~~~~~^~
0xe600af crash_signal
        ../../gcc-12-20210620/gcc/toplev.c:327
0xb85ab1 fold_const_aggregate_ref_1(tree_node*, tree_node* (*)(tree_node*))
        ../../gcc-12-20210620/gcc/gimple-fold.c:8184
0xb86e49 fold_const_aggregate_ref(tree_node*)
        ../../gcc-12-20210620/gcc/gimple-fold.c:8250
0xb86e49 maybe_fold_reference
        ../../gcc-12-20210620/gcc/gimple-fold.c:333
0xb8bc86 fold_gimple_assign
        ../../gcc-12-20210620/gcc/gimple-fold.c:483
0xb8bc86 fold_stmt_1
        ../../gcc-12-20210620/gcc/gimple-fold.c:6250
0xbd1071 gimplify_modify_expr
        ../../gcc-12-20210620/gcc/gimplify.c:5982
0xbb909f gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc-12-20210620/gcc/gimplify.c:14094
0xbbc9f6 gimplify_stmt(tree_node**, gimple**)
        ../../gcc-12-20210620/gcc/gimplify.c:6865
0xbbe8d6 gimplify_and_add(tree_node*, gimple**)
        ../../gcc-12-20210620/gcc/gimplify.c:494
0xbbe8d6 internal_get_tmp_var
        ../../gcc-12-20210620/gcc/gimplify.c:647
0xbb887e get_formal_tmp_var(tree_node*, gimple**)
        ../../gcc-12-20210620/gcc/gimplify.c:668
0xbb887e gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc-12-20210620/gcc/gimplify.c:15083
0xbb9363 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc-12-20210620/gcc/gimplify.c:14399
0xbd0dff gimplify_modify_expr
        ../../gcc-12-20210620/gcc/gimplify.c:5806
0xbb909f gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc-12-20210620/gcc/gimplify.c:14094
0xbbc9f6 gimplify_stmt(tree_node**, gimple**)
        ../../gcc-12-20210620/gcc/gimplify.c:6865
0xbc3c9d gimplify_and_add(tree_node*, gimple**)
        ../../gcc-12-20210620/gcc/gimplify.c:494
0xbc3c9d gimplify_decl_expr
        ../../gcc-12-20210620/gcc/gimplify.c:1831
0xbb939a gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc-12-20210620/gcc/gimplify.c:14291
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

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

$ gcc-sp11 --version
gcc (GCC) 11.1.1 20210619
Copyright (C) 2021 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.

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

$ gcc-sp11 36.c 
36.c:8:24: error: field ‘var’ has incomplete type
    8 |     struct this_struct var;
      |                        ^~~
36.c:17: confused by earlier errors, bailing out

Reply via email to