https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101914
Bug ID: 101914 Summary: internal compiler error: in tsubst, at cp/pt.c:15553 Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: accounts at prantare dot xyz Target Milestone: --- The following (preprocessed) code --- # 0 "main.cpp" # 0 "<built-in>" # 0 "<command-line>" # 1 "/usr/include/stdc-predef.h" 1 3 4 # 0 "<command-line>" 2 # 1 "main.cpp" template<class> struct A { int x; }; template<class T> A(T) -> A<T>; template<auto v> using B = decltype(A{v}); template<auto v> auto x = A<B<v>>{}; int main() { x<0>; } --- yields the following error message: --- main.cpp: In instantiation of ‘auto x<0>’: main.cpp:17:5: required from here main.cpp:13:6: internal compiler error: in tsubst, at cp/pt.c:15553 13 | auto x = A<B<v>>{}; | ^ 0x6eef60 tsubst(tree_node*, tree_node*, int, tree_node*) ../../gcc/gcc/cp/pt.c:15553 0xaeb4f4 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) ../../gcc/gcc/cp/pt.c:20630 0xb08797 tsubst(tree_node*, tree_node*, int, tree_node*) ../../gcc/gcc/cp/pt.c:16094 0xb0b174 tsubst_template_args(tree_node*, tree_node*, int, tree_node*) ../../gcc/gcc/cp/pt.c:13355 0xb14683 tsubst_aggr_type ../../gcc/gcc/cp/pt.c:13559 0xaeb4f4 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) ../../gcc/gcc/cp/pt.c:20630 0xaf62a7 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../gcc/gcc/cp/pt.c:19094 0xafd231 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../gcc/gcc/cp/pt.c:18108 0xafd231 tsubst_init ../../gcc/gcc/cp/pt.c:16452 0xafe252 regenerate_decl_from_template ../../gcc/gcc/cp/pt.c:25490 0xafe252 instantiate_body ../../gcc/gcc/cp/pt.c:25813 0xb001ea instantiate_decl(tree_node*, bool, bool) ../../gcc/gcc/cp/pt.c:26171 0x9e07aa maybe_instantiate_decl(tree_node*) ../../gcc/gcc/cp/decl2.c:5495 0x9e1739 maybe_instantiate_decl(tree_node*) ../../gcc/gcc/cp/decl2.c:5698 0x9e1739 mark_used(tree_node*, int) ../../gcc/gcc/cp/decl2.c:5724 0xb3f7b8 finish_id_expression_1 ../../gcc/gcc/cp/semantics.c:4132 0xb3fbb7 finish_id_expression(tree_node*, tree_node*, tree_node*, cp_id_kind*, bool, bool, bool*, bool, bool, bool, bool, char const**, unsigned int) ../../gcc/gcc/cp/semantics.c:4261 0xa9e152 cp_parser_primary_expression ../../gcc/gcc/cp/parser.c:6008 0xaa0aed cp_parser_postfix_expression ../../gcc/gcc/cp/parser.c:7566 0xa8a1aa cp_parser_binary_expression ../../gcc/gcc/cp/parser.c:9896 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. --- The command that triggers the bug: g++ main.cpp -std=c++20 Version et.c.: --- $ g++ -v: Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/12.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc/configure --disable-multilib Thread model: posix Supported LTO compression algorithms: zlib gcc version 12.0.0 20210813 (experimental) (GCC) --- The bug appears in 11.1.0 too, on two different machines. It compiles successfully with clang 14.