https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117969
Bug ID: 117969
Summary: internal compiler error: in
build_data_member_initialization, at
cp/constexpr.cc:453
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Keywords: ice-on-invalid-code
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
template<typename T, unsigned long N>
struct array
{
T a[N];
T* data() const { return a; }
unsigned long size() const { return N; }
};
template<typename T>
struct span
{
template<typename Iter>
constexpr explicit span(Iter first, unsigned long count)
: ptr(first), size(count)
{
if (__builtin_expect(!valid_range(first, first + count), 0))
throw;
}
template<typename U, unsigned long ArrayExtent>
constexpr
span(const array<U, ArrayExtent>& arr) noexcept
: span(static_cast<T*>(arr.data()), ArrayExtent)
{ }
T* ptr;
unsigned size;
};
struct A {
constexpr A(span<const unsigned char>) {}
};
constexpr A val{array<unsigned char, 2>{{0x11, 0x22}}};
s.cc:35:17: error: ‘constexpr span<T>::span(const array<U, ArrayExtent>&) [with
U = unsigned char; long unsigned int ArrayExtent = 2; T = const unsigned char]’
called in a constant expression
35 | constexpr A val{array<unsigned char, 2>{{0x11, 0x22}}};
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s.cc:23:5: note: ‘constexpr span<T>::span(const array<U, ArrayExtent>&) [with U
= unsigned char; long unsigned int ArrayExtent = 2; T = const unsigned char]’
is not usable as a ‘constexpr’ function because:
23 | span(const array<U, ArrayExtent>& arr) noexcept
| ^~~~
s.cc:23:5: internal compiler error: in build_data_member_initialization, at
cp/constexpr.cc:453
0x2809950 internal_error(char const*, ...)
/home/jwakely/src/gcc/gcc/gcc/diagnostic-global-context.cc:517
0xa24eff fancy_abort(char const*, int, char const*)
/home/jwakely/src/gcc/gcc/gcc/diagnostic.cc:1696
0x738702 build_data_member_initialization
/home/jwakely/src/gcc/gcc/gcc/cp/constexpr.cc:453
0xa770cc build_constexpr_constructor_member_initializers
/home/jwakely/src/gcc/gcc/gcc/cp/constexpr.cc:665
0xa770cc massage_constexpr_body
/home/jwakely/src/gcc/gcc/gcc/cp/constexpr.cc:789
0xa8c902 explain_invalid_constexpr_fn(tree_node*)
/home/jwakely/src/gcc/gcc/gcc/cp/constexpr.cc:1100
0xa79a8a cxx_eval_call_expression
/home/jwakely/src/gcc/gcc/gcc/cp/constexpr.cc:3121
0xa7b812 cxx_eval_constant_expression
/home/jwakely/src/gcc/gcc/gcc/cp/constexpr.cc:7579
0xa7d8eb cxx_eval_constant_expression
/home/jwakely/src/gcc/gcc/gcc/cp/constexpr.cc:7705
0xa784b3 cxx_bind_parameters_in_call
/home/jwakely/src/gcc/gcc/gcc/cp/constexpr.cc:1907
0xa784b3 cxx_eval_call_expression
/home/jwakely/src/gcc/gcc/gcc/cp/constexpr.cc:3059
0xa7b812 cxx_eval_constant_expression
/home/jwakely/src/gcc/gcc/gcc/cp/constexpr.cc:7579
0xa8816f cxx_eval_outermost_constant_expr
/home/jwakely/src/gcc/gcc/gcc/cp/constexpr.cc:8868
0xa8e002 maybe_constant_init_1
/home/jwakely/src/gcc/gcc/gcc/cp/constexpr.cc:9379
0xd04e6c store_init_value(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
/home/jwakely/src/gcc/gcc/gcc/cp/typeck2.cc:909
0xadcc10 check_initializer
/home/jwakely/src/gcc/gcc/gcc/cp/decl.cc:7877
0xb07c55 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int,
cp_decomp*)
/home/jwakely/src/gcc/gcc/gcc/cp/decl.cc:8937
0xc15798 cp_parser_init_declarator
/home/jwakely/src/gcc/gcc/gcc/cp/parser.cc:23955
0xc1c8c1 cp_parser_simple_declaration
/home/jwakely/src/gcc/gcc/gcc/cp/parser.cc:16201
0xc26f35 cp_parser_declaration
/home/jwakely/src/gcc/gcc/gcc/cp/parser.cc:15874
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.