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

            Bug ID: 125315
           Summary: [16/17 Regression] ICE in init_subob_ctx with empty
                    [[no_unique_address]] member [PR123346]
           Product: gcc
           Version: 16.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dale.oystein at gmail dot com
  Target Milestone: ---

Created attachment 64460
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=64460&action=edit
Minimal repro

Compiling the attached code produces the below ICE.

This happens when descending into the initializer of a sub-aggregate whose
enclosing empty subobject has had its CONSTRUCTOR tree node elided (set to
NULL) by init_subob_ctx. On the next recursion, both ctx->ctor and ctx->object
are NULL, hitting gcc_unreachable().

Issue is not present in GCC 15.2. Issue can be reproduced both in GCC 16.1 and
in trunk.

Bisecting suggests commit
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=92a1d876b20426ebd240ad9bd65d9bce2705611d
(c++: fix constexpr union with empty member [PR123346]) has introduced the
issue.

https://godbolt.org/z/5Kd398dcP

$ gcc -freport-bug minimal.cpp                         
minimal.cpp:6:16: internal compiler error: in init_subob_ctx, at
cp/constexpr.cc:6706
    6 | auto x=R{{f(s)}};
      |                ^
0x27e6438 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
        ???:0
0x27e8a47 internal_error(char const*, ...)
        ???:0
0x737816 fancy_abort(char const*, int, char const*)
        ???:0
0x78fbb8 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
        ???:0
0x78fbb8 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
        ???:0
0x7a61e3 maybe_constant_value(tree_node*, tree_node*, mce_value)
        ???:0
0x7c722b cp_fully_fold_init(tree_node*)
        ???:0
0xa2a716 split_nonconstant_init(tree_node*, tree_node*)
        ???:0
0x7ff1ed cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int,
cp_decomp*)
        ???:0
0xaaa200 c_common_parse_file()
        ???:0
/usr/lib/gcc/x86_64-pc-linux-gnu/16.1.1/cc1plus -quiet -D_GNU_SOURCE
minimal.cpp -quiet -dumpdir a- -dumpbase minimal.cpp -dumpbase-ext .cpp
-mtune=generic -march=x86-64 -freport-bug -o /tmp/cchkK1eu.s
Please submit a full bug report, with preprocessed source.
Please include the complete backtrace with any bug report.
See <https://gitlab.archlinux.org/archlinux/packaging/packages/gcc/-/issues>
for instructions.
Preprocessed source stored into /tmp/cc78JBov.out file, please attach this to
your bugreport.

System: Arch Linux, last updated 2026-05-07.

$ gcc --version
gcc (GCC) 16.1.1 20260430
Copyright (C) 2026 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.

Reply via email to