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

            Bug ID: 123452
           Summary: ICE: Segmentation fault during error reporting for
                    invalid bit-field initialization
           Product: gcc
           Version: 15.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: 522024330006 at smail dot nju.edu.cn
  Target Milestone: ---

To reproduce: https://godbolt.org/z/f64Kej8vf

The crash occurs in `process_init_constructor_union` when attempting to digest
the initializer for an array of a struct that contains a malformed
union/bit-field.

Program:
```
#include <string.h>

struct bfield_struct {
   union {
       unsigned short us_bf : { 
           unsigned a:8;
       };
   };
};

int main() {
    struct bfield_struct bf_vals[]({
        {.a=1}
    });
}
```

Part of the traceback:
```
Segmentation fault
0x5da1dc8 internal_error(char const*, ...)
        /workspace/install/gcc/src/gcc/gcc/diagnostic-global-context.cc:517
0x273a9a4 crash_signal
        /workspace/install/gcc/src/gcc/gcc/toplev.cc:322
0x7ffff79d932f ???
        ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0x11823b8 cp_printer
        /workspace/install/gcc/src/gcc/gcc/cp/error.cc:4711
0x5df8091 format_phase_2
        /workspace/install/gcc/src/gcc/gcc/pretty-print.cc:2158
0x5df4514 pretty_printer::format(text_info&)
        /workspace/install/gcc/src/gcc/gcc/pretty-print.cc:1711
0x18ac446 pp_format(pretty_printer*, text_info*)
        /workspace/install/gcc/src/gcc/gcc/pretty-print.h:594
0x5d3e8a4 diagnostic_context::report_diagnostic(diagnostic_info*)
        /workspace/install/gcc/src/gcc/gcc/diagnostic.cc:1505
0x5d3f2b7 diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
        /workspace/install/gcc/src/gcc/gcc/diagnostic.cc:1641
0x5da0e75 error(char const*, ...)
        /workspace/install/gcc/src/gcc/gcc/diagnostic-global-context.cc:397
0x16f5799 process_init_constructor_union
        /workspace/install/gcc/src/gcc/gcc/cp/typeck2.cc:2039
0x16f5ede process_init_constructor
        /workspace/install/gcc/src/gcc/gcc/cp/typeck2.cc:2114
0x16f0c53 digest_init_r
        /workspace/install/gcc/src/gcc/gcc/cp/typeck2.cc:1406
0x16f1bb8 massage_init_elt
        /workspace/install/gcc/src/gcc/gcc/cp/typeck2.cc:1573
0x16f3a63 process_init_constructor_record
        /workspace/install/gcc/src/gcc/gcc/cp/typeck2.cc:1816
0x16f5e8c process_init_constructor
        /workspace/install/gcc/src/gcc/gcc/cp/typeck2.cc:2111
0x16f0c53 digest_init_r
        /workspace/install/gcc/src/gcc/gcc/cp/typeck2.cc:1406
0x16f1013 digest_init(tree_node*, tree_node*, int)
        /workspace/install/gcc/src/gcc/gcc/cp/typeck2.cc:1446
0x11a7d8d expand_default_init
        /workspace/install/gcc/src/gcc/gcc/cp/init.cc:2131
0x11a96c9 expand_aggr_init_1
        /workspace/install/gcc/src/gcc/gcc/cp/init.cc:2361
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