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

            Bug ID: 102120
           Summary: expected tree that contains 'decl common' structure,
                    have 'identifier_node' in dump_aggr_type, at
                    cp/error.c:786
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: blubban at gmail dot com
  Target Milestone: ---

Input:


union U {
        int value;
        constexpr ~U() noexcept { }
};

constexpr int z() {
    U* array = new U[5];
    int result = array[3].value;
    delete[] array;
    return result;
}

constexpr int zz = z();


Compile with -std=c++20.

Expected output (I get this if I remove the union's dtor, or change the array
to a single object):


<source>:13:21:   in 'constexpr' expansion of 'z()'
<source>:13:22: error: the content of uninitialized storage is not usable in a
constant expression
   13 | constexpr int zz = z();
      |                      ^
<source>:7:23: note: allocated here
    7 |     U* array = new U[5];
      |                       ^


Actual output on GCC 11.2:


'
<source>:13: confused by earlier errors, bailing out


Yes, those two lines are the entirety of its output.

GCC trunk is slightly better, but still asks for a bug report:


'
<source>:13:21:   in 'constexpr' expansion of 'z()'
tree check: expected tree that contains 'decl common' structure, have
'identifier_node' in dump_aggr_type, at cp/error.c:786
   13 | constexpr int zz = z();
      |                      ^
0x1f30289 internal_error(char const*, ...)
        ???:0
0x6bb645 tree_contains_struct_check_failed(tree_node const*,
tree_node_structure_enum, char const*, int, char const*)
        ???:0
0x1f4c781 pp_format(pretty_printer*, text_info*)
        ???:0
0x1f2eeb5 diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*)
        ???:0
0x1f2fde9 error(char const*, ...)
        ???:0
0xae3d0a store_init_value(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
        ???:0
0x89b0c9 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
        ???:0
0x9d09a5 c_parse_file()
        ???:0
0xb55af2 c_common_parse_file()
        ???:0
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.


Compiler Explorer: https://godbolt.org/z/WETs8jbMG

Posted by user konstantinua00 on the Compiler Explorer Discord, who may or may
not have found it via someone else.

Reply via email to