https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91023
Bug ID: 91023 Summary: Unification Fails for parameter pack Product: gcc Version: 9.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: christoph.hoeger at celeraone dot com Target Milestone: --- Created attachment 46529 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46529&action=edit Automatically generated preprocessed output In the example below, the unification of the template argument fails with the message: ➜ gcc.bug g++ --std=c++17 input.cpp input.cpp: In substitution of 'template<class ... T> std::optional<std::variant<_Types ...> > parse_variant(const Foo<T, std::variant<_Types ...> >& ...) [with T = <missing>]': input.cpp:33:43: required from here input.cpp:33:43: internal compiler error: in tsubst, at cp/pt.c:14560 33 | const auto x = parse_variant(a(), b()); | ^ Please submit a full bug report, with preprocessed source if appropriate. See <http://bugzilla.redhat.com/bugzilla> for instructions. Preprocessed source stored into /tmp/cc1jpH2s.out file, please attach this to your bugreport. distcc[31035] ERROR: compile input.cpp on localhost failed Example: #include <variant> #include <optional> template <typename T, typename S> struct Foo { }; template <typename... T> std::optional<std::variant<T...>> parse_variant(const Foo<T, std::variant<T...>> &... variants) { return {}; } struct A {}; struct B {}; using var_test = std::variant<A, B>; Foo<A, var_test> a() { return {}; } Foo<B, var_test> b() { return {}; } int main() { const auto x = parse_variant(a(), b()); return 0; } gcc version information: ➜ gcc.bug g++ -v Using built-in specs. COLLECT_GCC=/usr/bin/g++ COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/9/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-redhat-linux Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --enable-offload-targets=nvptx-none --without-cuda-driver --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux Thread model: posix gcc version 9.1.1 20190503 (Red Hat 9.1.1-1) (GCC)