https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105589
Bug ID: 105589
Summary: [ICE] templated type alias over std::array with bound
type in template function fails
Product: gcc
Version: 12.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: cuzdav at gmail dot com
Target Milestone: ---
Created attachment 52969
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52969&action=edit
preprocessed code
Internal compiler error - new in gcc12
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/imc/gcc-12.1.0/libexec/gcc/x86_64-pc-linux-gnu/12.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-12.1.0/configure --prefix=/opt/imc/gcc-12.1.0
--enable-languages=c,c++,fortran,lto --disable-multilib
--with-build-time-tools=/home/trading/cuzdav/code/imc-gcc/gcc/12.1.0/INSTALLDIR//opt/imc/gcc-12.1.0/bin
--enable-libstdcxx-time=rt
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.1.0 (GCC)
Spent a long time minimizing it to this example, so it's contrived but small.
The user-provided constructor in the element type seems related.
The auto parameter in form() is also necessary, even if unused.
///////////////////////////////////////////////
#include <array>
struct X {
X() {}
};
template<int N>
using C = std::array<X, N>;
void form(auto) {
auto w = C<16>{};
}
///////////////////////////////////////////////
LIVE:
(Also visible on the 12.1 on godbolt)
https://godbolt.org/z/qWba56onf
OUTPUT:
foo2.cpp: In function ‘void form(auto:3)’:
foo2.cpp:11:18: internal compiler error: in build_value_init, at cp/init.cc:347
11 | auto w = C<16>{};
| ^
0x1b1211a diagnostic_impl(rich_location*, diagnostic_metadata const*, int, char
const*, __va_list_tag (*) [1], diagnostic_t)
???:0
0x13637ff internal_error(char const*, ...)
???:0
0x13638d1 fancy_abort(char const*, int, char const*)
???:0
0x7665e6 build_value_init(tree_node*, int) [clone .cold]
???:0
0x1901bb1 build_vec_init_expr(tree_node*, tree_node*, int)
???:0
0x809217 digest_init_r(tree_node*, tree_node*, int, int, int) [clone .cold]
???:0
0x157c0ca massage_init_elt(tree_node*, tree_node*, int, int, int)
???:0
0x8096e7 digest_init_r(tree_node*, tree_node*, int, int, int) [clone .cold]
???:0
0x18ff96c finish_compound_literal(tree_node*, tree_node*, int, fcl_t)
???:0
0x15453de cp_parser_functional_cast(cp_parser*, tree_node*)
???:0
0x153e4ac cp_parser_postfix_expression(cp_parser*, bool, bool, bool, bool,
cp_id_kind*)
???:0
0x153c5dc cp_parser_binary_expression(cp_parser*, bool, bool, bool,
cp_parser_prec, cp_id_kind*)
???:0
0x153c2b2 cp_parser_assignment_expression(cp_parser*, cp_id_kind*, bool, bool)
???:0
0x153c130 cp_parser_constant_expression(cp_parser*, int, bool*, bool)
???:0
0x153bf7b cp_parser_initializer(cp_parser*, bool*, bool*, bool)
???:0
0x7a2ea4 cp_parser_init_declarator(cp_parser*, int, cp_decl_specifier_seq*,
vec<deferred_access_check, va_gc, vl_embed>*, bool, bool, int, bool*,
tree_node**, unsigned int*, tree_node**) [clone .cold]
???:0
0x15300c5 cp_parser_simple_declaration(cp_parser*, bool, tree_node**)
???:0
0x1542170 cp_parser_declaration_statement(cp_parser*)
???:0
0x1540bf3 cp_parser_statement(cp_parser*, tree_node*, bool, bool*,
vec<tree_node*, va_heap, vl_ptr>*, unsigned int*)
???:0
0x1540657 cp_parser_compound_statement(cp_parser*, tree_node*, int, bool)
???: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.
Preprocessed code attached.