[clang] [clang] CTAD alias: Respect explicit deduction guides defined after the first use of the alias template. (PR #125478)
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 5 00:48:27 PST 2025
================
@@ -237,8 +237,17 @@ static_assert(__is_same(decltype(s.t), int));
// explicit deduction guide.
Foo(int) -> Foo<X>;
AFoo s2{i};
-// FIXME: the type should be X because of the above explicit deduction guide.
-static_assert(__is_same(decltype(s2.t), int));
+static_assert(__is_same(decltype(s2.t), X));
+
+
+template<class T>
+using BFoo = AFoo<T>;
+static_assert(__is_same(decltype(BFoo(i).t), X));
+
+
+Foo(double) -> Foo<int>;
+static_assert(__is_same(decltype(AFoo(1.0).t), int));
+static_assert(__is_same(decltype(BFoo(1.0).t), int));
----------------
hokein wrote:
> https://compiler-explorer.com/z/x8PhEqWeo
A simpler example: https://compiler-explorer.com/z/Tdx1jd1bM
I think Clang (and MSVC) are correct in rejecting this example. The candidate deduction guide `(AFoo(T t, U) -> Foo<T, U>)` is not selected because the `is_deducible` type trait is not satisfied, as indicated in the diagnostic message.
It looks like a bug in gcc.
https://github.com/llvm/llvm-project/pull/125478
More information about the cfe-commits
mailing list