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

            Bug ID: 123174
           Summary: Internal compiler error: cxx_eval_store_expression
                    with structured binding of class containing array of
                    abstract type
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Keywords: error-recovery, ice-checking, ice-on-invalid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: attackerj1113 at gmail dot com
  Target Milestone: ---

The following code causes ICE out on x86-64 gcc since version 14.3(assertions)
and reproducible on trunk:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
struct A {
    virtual void f() = 0;
};

struct B {
    A a[1];
};

B b{};
auto [x] = b;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Clang reports the error correctly,

Please check https://godbolt.org/z/6fzGTzjse

GCC crashes with an internal compiler error in cxx_eval_store_expression when
compiling a structured binding of a class that contains an array member of an
abstract type.

Compiler Output:
<source>:6:7: error: cannot declare field 'B::a' to be of abstract type 'A'
    6 |     A a[1];
      |       ^
<source>:1:8: note: because the following virtual functions are pure within
'A':
    1 | struct A {
      |        ^
  • 'virtual void A::f()'
    <source>:2:18:
        2 |     virtual void f() = 0;
          |                  ^
<source>:9:5: error: cannot construct an object of abstract type 'A'
    9 | B b{};
      |     ^
<source>: In copy constructor 'constexpr B::B(const B&)':
<source>:5:8: error: cannot construct an object of abstract type 'A'
    5 | struct B {
      |        ^
<source>: At global scope:
<source>:10:12: note: synthesized method 'constexpr B::B(const B&)' first
required here
   10 | auto [x] = b;
      |            ^
in 'constexpr' expansion of 'B(b)'
<source>:10:12:   
<source>:5:8: internal compiler error: in cxx_eval_store_expression, at
cp/constexpr.cc:7933
    5 | struct B {
      |        ^
0x29084d8 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
        ???:0
0x28fd29b internal_error(char const*, ...)
        ???:0
0xb11112 fancy_abort(char const*, int, char const*)
        ???:0
0xe3f7a5 store_init_value(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
        ???:0
0xc1793e cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int,
cp_decomp*)
        ???:0
0xd4f5d3 c_parse_file()
        ???:0
0xec0679 c_common_parse_file()
        ???:0
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.
Compiler returned: 1

Reply via email to