https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114903
Bug ID: 114903 Summary: constraint of CTAD alias deduction guide is evaluated on a wrong type Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: hokein.wu at gmail dot com Target Milestone: --- See the following example of nested templates: ``` #include <type_traits> template <typename T> struct Key { Key(int); }; class Forward {}; template <typename T> constexpr bool C = std::is_same<T, Forward>(); // changing `Forward` to `double` will make the following static_assert passed. template <typename Z> struct Outer { template <typename U> struct Foo { Foo(U); U u; }; template <typename V> requires(C<Z>) Foo(V) -> Foo<int>; }; template <typename Y> struct T { template <typename Y2> struct T2 { template <typename K> using AFoo = Outer<Y2>::template Foo<K>; }; }; T<Forward>::T2<Forward>::AFoo a{1.0}; // the explict deduction guide should be choosen, Foo<int> static_assert(std::is_same<decltype(a), Outer<Forward>::Foo<int>>()); // expect to be true! ``` The constraint `C` in the alias deduction guide should be true, as it is evaluated on type `Forward`, but gcc seems to evaluate it on `double`.