llvm-project
59b0935b - [Clang] Treat address-of template substitution as SFINAE

Commit
21 days ago
[Clang] Treat address-of template substitution as SFINAE Taking the address of a function template specialization can instantiate its trailing return type as part of a SFINAE probe: struct X {}; template <class T> void f(T) = delete; template <class T> auto probe(T t) -> decltype(f(t), void()); template <class T, class = decltype(&probe<T>)> int test(int); template <class T> char test(...); static_assert(sizeof(test<X>(0)) == sizeof(char)); Here, substituting the return type of probe<X> selects the deleted f<X>. The deleted call is in the immediate context of substitution, so it should remove test(int) from overload resolution. GCC accepts this example. Clang instead kept deduction as successful and later replayed the stored diagnostic as a hard error. The call-deduction path already checks the SFINAE trap after finishing template argument deduction. Do the same for the address-of path, so the stored diagnostic is not replayed after deduction succeeds.
Author
Parents
Loading