https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118626
Bug ID: 118626 Summary: C++20 std::variant causes a segmentation fault Product: gcc Version: 13.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: JanPapuch at seznam dot cz Target Milestone: --- This issue may be a regression of [Bug 104470](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104470). Output of `gcc -v -save-temps --std=c++20 main.cpp`: ``` Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-linux-gnu/13/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 13.1.0-8ubuntu1~20.04.2' --with-bugurl=file:///usr/share/doc/gcc-13/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2,rust --prefix=/usr --with-gcc-major-version-only --program-suffix=-13 --program-prefix=x86_64-linux-gnu- -- enable-shared --enable-linker-build-id --libexecdir=/usr/libexec --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --en able-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 13.1.0 (Ubuntu 13.1.0-8ubuntu1~20.04.2) COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++20' '-mtune=generic' '-march=x86-64' '-dumpdir' 'a-' /usr/libexec/gcc/x86_64-linux-gnu/13/cc1plus -E -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE main.cpp -mtune=generic -march=x86-64 -std=c++20 -fpch-preprocess -fasynchronous-unwind-tables -fstack-protector-strong -Wformat -Wformat-security -fstack-clash-protection -fcf-protection -o a-main.ii ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/13" ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu" ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/13/include-fixed/x86_64-linux-gnu" ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/13/include-fixed" ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/13/../../../../x86_64-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /usr/include/c++/13 /usr/include/x86_64-linux-gnu/c++/13 /usr/include/c++/13/backward /usr/lib/gcc/x86_64-linux-gnu/13/include /usr/local/include /usr/include/x86_64-linux-gnu /usr/include End of search list. COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++20' '-mtune=generic' '-march=x86-64' '-dumpdir' 'a-' /usr/libexec/gcc/x86_64-linux-gnu/13/cc1plus -fpreprocessed a-main.ii -quiet -dumpdir a- -dumpbase main.cpp -dumpbase-ext .cpp -mtune=generic -march=x86-64 -std=c++20 -version -fasynchronous-unwind-tables -fstack-protector-strong -Wformat -Wformat-security -fstack-clash-protection -fcf-protection -o a-main.s GNU C++20 (Ubuntu 13.1.0-8ubuntu1~20.04.2) version 13.1.0 (x86_64-linux-gnu) compiled by GNU C version 13.1.0, GMP version 6.2.0, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.22.1-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 391880e3be75f4e1ac78bddcb50fff0c In file included from main.cpp:2: /usr/include/c++/13/variant: In substitution of ‘template<class ... _Types> template<class _Tp, class> using std::variant<_Types>::__accepted_type = std::variant<_Types>::__to_type<__accepted_index<_Tp> > [with _Tp = _Tp&&; <template-parameter-2-2> = typename std::enable_if<std::variant<Node<L, R>, Leaf>::__not_self<_Tp&&>, void>::type; _Types = {Node<L, R>, Leaf}]’: main.cpp:43:9: required from here /usr/include/c++/13/variant:1383:43: internal compiler error: Segmentation fault 1383 | using __accepted_type = __to_type<__accepted_index<_Tp>>; | ^~~~~~~~~~~~~~~~~~~~ 0xdd3543 crash_signal ../../src/gcc/toplev.cc:314 0x7f01cdb5308f ??? /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0 0x84c3eb tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*) ../../src/gcc/cp/pt.cc:20450 0x85bf30 tsubst_expr(tree_node*, tree_node*, int, tree_node*) ../../src/gcc/cp/pt.cc:19895 0x85ff09 tsubst_template_args(tree_node*, tree_node*, int, tree_node*) ../../src/gcc/cp/pt.cc:13766 0x8601b2 tsubst_template_args(tree_node*, tree_node*, int, tree_node*) ../../src/gcc/cp/pt.cc:13748 0x85037a tsubst(tree_node*, tree_node*, int, tree_node*) ../../src/gcc/cp/pt.cc:15966 0x85a562 tsubst_decl ../../src/gcc/cp/pt.cc:15307 0x868e73 instantiate_template(tree_node*, tree_node*, int) ../../src/gcc/cp/pt.cc:22132 0x8503fe instantiate_alias_template ../../src/gcc/cp/pt.cc:22215 0x8503fe tsubst(tree_node*, tree_node*, int, tree_node*) ../../src/gcc/cp/pt.cc:15967 0x870567 rewrite_tparm_list ../../src/gcc/cp/pt.cc:29761 0x870d93 alias_ctad_tweaks ../../src/gcc/cp/pt.cc:30259 0x847904 deduction_guides_for ../../src/gcc/cp/pt.cc:30494 0x847ad7 do_class_deduction ../../src/gcc/cp/pt.cc:30641 0x847ad7 do_auto_deduction(tree_node*, tree_node*, tree_node*, int, auto_deduction_context, tree_node*, int, tree_node*) ../../src/gcc/cp/pt.cc:30841 0x88179f finish_compound_literal(tree_node*, tree_node*, int, fcl_t) ../../src/gcc/cp/semantics.cc:3213 0x7fa14c cp_parser_functional_cast ../../src/gcc/cp/parser.cc:32611 0x80b203 cp_parser_postfix_expression ../../src/gcc/cp/parser.cc:7703 0x7f382c cp_parser_binary_expression ../../src/gcc/cp/parser.cc:10147 Please submit a full bug report, with preprocessed source (by using -freport-bug). Please include the complete backtrace with any bug report. See <file:///usr/share/doc/gcc-13/README.Bugs> for instructions. ```