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

            Bug ID: 124973
           Summary: [16 regression] ICE w/ modules, constexpr, and O[1-3]
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marcel at laverdet dot com
  Target Milestone: ---

// left.cc
export module left;
import right;

export auto xx(environment&) -> void;

// right.cc
export module right;

struct constexpr_move {
    constexpr_move() = default;
    constexpr_move(const constexpr_move&) = default;
    constexpr constexpr_move(constexpr_move&&) {}
};

struct element {
    constexpr_move a;
    int b;
};

template <unsigned N>
struct element_array {
    element data[ N ];
};

template <unsigned N>
struct holder {
    consteval holder(element_array<N> values) :
        values_{static_cast<element_array<N>&&>(values)} {}
    element_array<N> values_;
};

template <unsigned N>
constexpr auto holder_of = holder<N>{element_array<N>{}};

export class environment {
    decltype(holder_of<1>) s1_{holder_of<1>};
    decltype(holder_of<2>) s2_{holder_of<2>};
};

-----

$ g++ --version
g++ (Debian 15.2.0-8) 15.2.0
Copyright (C) 2025 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.

$ g++ -O3 -std=c++23 -fmodules-ts -c right.cc
$ g++ -O3 -std=c++23 -fmodules-ts -c left.cc

-----

$ /root/gcc-16/bin/g++ --version
g++ (GCC) 16.0.1 20260415 (experimental)
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.

$ /root/gcc-16/bin/g++ -O0 -std=c++23 -fmodules-ts -c right.cc
$ /root/gcc-16/bin/g++ -O0 -std=c++23 -fmodules-ts -c left.cc

-----

$ /root/gcc-16/bin/g++ --version
g++ (GCC) 16.0.1 20260415 (experimental)
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.

$ /root/gcc-16/bin/g++ -O1 -std=c++23 -fmodules-ts -c right.cc
$ /root/gcc-16/bin/g++ -O1 -std=c++23 -fmodules-ts -c left.cc
In module right, imported at left.cc:2:
right.cc: In constructor ‘constexpr element@right::element(element@right&&)’:
right.cc:22:13:   in ‘constexpr’ expansion of ‘element_array@right<2>(values)’
   22 |                                
values_{static_cast<element_array<N>&&>(values)} {}
      |                                        
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
right.cc:22:13:   in ‘constexpr’ expansion of ‘element_array@right<1>(values)’
right.cc:9:8: internal compiler error: Segmentation fault
    9 | struct element {
      |        ^~~~~~~
0x26db5b3 internal_error(char const*, ...)
        /gcc-out/../gcc/gcc/diagnostic-global-context.cc:787
0x141edfb crash_signal
        /gcc-out/../gcc/gcc/toplev.cc:325
0xa2485c emit_mem_initializers(tree_node*)
        /gcc-out/../gcc/gcc/cp/init.cc:1565
0xa56f17 do_build_copy_constructor
        /gcc-out/../gcc/gcc/cp/method.cc:789
0xa56f17 synthesize_method(tree_node*)
        /gcc-out/../gcc/gcc/cp/method.cc:1832
0x9eb207 mark_used(tree_node*, int)
        /gcc-out/../gcc/gcc/cp/decl2.cc:6866
0x8ac23f build_over_call
        /gcc-out/../gcc/gcc/cp/call.cc:10924
0x8a8b13 build_new_method_call(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, tree_node*, int, tree_node**, int)
        /gcc-out/../gcc/gcc/cp/call.cc:12317
0x8a9d1b build_special_member_call(tree_node*, tree_node*, vec<tree_node*,
va_gc, vl_embed>**, tree_node*, int, int)
        /gcc-out/../gcc/gcc/cp/call.cc:11800
0x8ae967 build_temp
        /gcc-out/../gcc/gcc/cp/call.cc:8498
0x8ae967 convert_like_internal
        /gcc-out/../gcc/gcc/cp/call.cc:9255
0x8bbd13 convert_like
        /gcc-out/../gcc/gcc/cp/call.cc:9513
0x8bbd13 perform_implicit_conversion_flags(tree_node*, tree_node*, int, int)
        /gcc-out/../gcc/gcc/cp/call.cc:14136
0x91a64f cxx_eval_vec_init_1
        /gcc-out/../gcc/gcc/cp/constexpr.cc:7025
0x91abdf cxx_eval_vec_init
        /gcc-out/../gcc/gcc/cp/constexpr.cc:7121
0x90c1df cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
        /gcc-out/../gcc/gcc/cp/constexpr.cc:10049
0x9140b3 cxx_eval_store_expression
        /gcc-out/../gcc/gcc/cp/constexpr.cc:8313
0x90a237 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
        /gcc-out/../gcc/gcc/cp/constexpr.cc:9543
0x90ae97 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
        /gcc-out/../gcc/gcc/cp/constexpr.cc:10084
0x90b1cf cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
        /gcc-out/../gcc/gcc/cp/constexpr.cc:9588
/root/gcc-16/libexec/gcc/aarch64-unknown-linux-gnu/16.0.1/cc1plus -quiet
-imultiarch aarch64-linux-gnu -D_GNU_SOURCE left.cc -quiet -dumpbase left.cc
-dumpbase-ext .cc -mlittle-endian -mabi=lp64 -O1 -std=c++23 -fmodules -o
/tmp/ccZKrQZZ.s
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