-
Notifications
You must be signed in to change notification settings - Fork 13.6k
"is not a structural type" should be a substitution failure #71684
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
Comments
Workaround in this specific case is to change the test to: template<auto> struct test {};
template<class T, template<T> class> struct test2;
template<class T> concept structural = requires { typename test2<T, test>; }; |
@llvm/issue-subscribers-clang-frontend Author: Ed Catmur (ecatmur)
On CE trunk 20231108 18.0.0 (https://github.com/llvm/llvm-project.git fb07d9c):
```c++
template<auto> struct test {};
template<class T> concept structural = requires { []<T x>(test<x>) {}; };
class C { int i; };
static_assert(not structural<C>);
```
(reduced from https://stackoverflow.com/a/68856187/567292)
fails with hard error:
Previously (13.0.0 through 17.0.1) this was a substitution failure, which I think it should be. |
@llvm/issue-subscribers-c-20 Author: Ed Catmur (ecatmur)
On CE trunk 20231108 18.0.0 (https://github.com/llvm/llvm-project.git fb07d9c):
```c++
template<auto> struct test {};
template<class T> concept structural = requires { []<T x>(test<x>) {}; };
class C { int i; };
static_assert(not structural<C>);
```
(reduced from https://stackoverflow.com/a/68856187/567292)
fails with hard error:
Previously (13.0.0 through 17.0.1) this was a substitution failure, which I think it should be. |
I think this is #64138. |
Sorry, I closed the issue too quickly: As CWG2672 says, it is that
which, seems not to cover the substitution for the parameter part of a lambda expression. @zygoloid Do you think we should regard the non-body parts for a lambda as SFINAE context? (@cor3ntin also pointed that in https://reviews.llvm.org/D156993#4557292) Another question is, shall we update the examples for [temp.deduct]p9 as well? e.g., template <class T>
auto h(T) -> decltype([x = T::invalid]() { });
void h(...);
h(0); // error: invalid expression not part of the immediate context This should compile now IIUC. (I didn't see the related changes in the DR, but it could be I have overlooked something.) |
Friendly ping @cor3ntin and @zygoloid. Also cc @AaronBallman for help. |
Here's the resolution of CWG2672, which is in the middle of being merged into the standard right now: cplusplus/draft@389a869 Seems pretty clear that it's only the body of the lambda that's outside the immediate context, so SFINAE should apply here. |
Filed an editorial issue to fix the example and hopefully move the wording somewhere more central: cplusplus/draft#6718 |
This is a follow-up patch for [D156993](https://reviews.llvm.org/D156993), that marks only the lambda body as non-immediate context. Fixes llvm#71684
Thank you Richard for clarification (and editorial fixes). Filed #75001 for it. |
On CE trunk 20231108 18.0.0 (https://github.com/llvm/llvm-project.git fb07d9c):
(reduced from https://stackoverflow.com/a/68856187/567292)
fails with hard error:
Previously (13.0.0 through 17.0.1) this was a substitution failure, which I think it should be.
The text was updated successfully, but these errors were encountered: