-
Notifications
You must be signed in to change notification settings - Fork 12.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clang] Incomplete treatment for non-deduced context with nested template #121208
Comments
@llvm/issue-subscribers-clang-frontend Author: A. Jiang (frederick-vs-ja)
Currently, Clang doesn't accept the following code snippet, while other implementations do ([demo](https://godbolt.org/z/Yccjc95Eb)).
template <template <typename> class>
struct B;
struct C {
template <typename>
struct Nested;
};
template <typename T>
void f(T*, B<T::template Nested>*);
void g(C *cp, B<C::template Nested>* bcnp) {
f(cp, 0);
} When The following similar example is rejected by all implemenations (demo), and shows that Clang also considers that template <template <typename> class>
struct B;
struct C {
template <typename>
struct Nested;
};
template <typename T>
void f(T*, B<T::template Nested>*);
void g(C *cp, B<C::template Nested>* bcnp) {
f({}, bcnp);
} Given that |
The following case does not rely (in the wording: https://wg21.link/temp.spec.partial.match#3) on the definition of non-deduced context. template <template <typename> class>
struct B;
template <typename T>
struct B<T::template Nested>; It seems both Clang and GCC have a bug here: https://godbolt.org/z/qvfGYhWT4 |
CC @erichkeane |
Currently, Clang doesn't accept the following code snippet, while other implementations do (demo).
When
0
is replaced with{}
(but notnullptr
or any real null pointer constant), Clang also accept it (demo).The following similar example is rejected by all implemenations (demo), and shows that Clang also considers that
T
is not deducible fromB<T::template Nested>*
(and thusB<T::template Nested>*
forms non-deduced context forT
). Although the current standard wording is possibly defective on this (see cplusplus/CWG#660).Given that
T
is (or should be considered) in the non-deduced context inB<T::template Nested>*
, Clang should not try to matchB<T::template Nested>*
againstint
(orstd::nullptr_t
), and should just take0
(ornullptr
) as null pointer constant instead.The text was updated successfully, but these errors were encountered: