Skip to content
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

Templated Lambda with requires clause defined inside concept crash when instantiated constraints. #58368

Closed
erichkeane opened this issue Oct 14, 2022 · 6 comments
Assignees
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" concepts C++20 concepts crash Prefer [crash-on-valid] or [crash-on-invalid]

Comments

@erichkeane
Copy link
Collaborator

As reported here: https://reviews.llvm.org/D126907 and reproduced here: https://cute.godbolt.org/z/Prh6xsesz

Lambdas that are defined inside of a concept and have a requires clause crash while instantiating their requires clause, because we don't add the concept's template arguments to the MultiLevelTemplateArgumentList.

Typically, we 'rebuild' the template argument lists by walking back through the instantiated Decls. However in this case, the lambda is defined inside of a ConceptSpecializationExpr, which doesn't really exist inside of a decl-context-tree. I'll have to figure out how to make the Expr a context for the purposes of rebuilding these template argument lists.

This gets more troublesome with nested lambdas, and it isn't clear when we might be off trying to instantiate a DIFFERENT dependency (that is, if the lambda's requires clause causes a different requires clause, outside of the concept to be evaluated).

I'm still looking at this, but want to capture this before the weekend.

@erichkeane erichkeane added the concepts C++20 concepts label Oct 14, 2022
@erichkeane erichkeane self-assigned this Oct 14, 2022
@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" crash Prefer [crash-on-valid] or [crash-on-invalid] labels Oct 14, 2022
@llvmbot
Copy link
Collaborator

llvmbot commented Oct 14, 2022

@llvm/issue-subscribers-clang-frontend

@royjacobson
Copy link
Contributor

That sounds suspiciously close to #56154 which is about concept normalization 'forgetting' the concept template arguments.

@erichkeane
Copy link
Collaborator Author

I don't believe this is related at all, the fact pattern is a lambda with a requires clause defined inside a concept, which causes the template arguments to not be correct when checking the lambda's requires clause.

This is going to requite a new Decl kind for a concept-specialization, which I was working on friday.

@erichkeane
Copy link
Collaborator Author

As an update, I've come up with a patch that is not quite ready for review (I have a ton of TODOs) that proves out my idea of splitting ConceptSpecializationExpr into ConceptSpecializationDecl and ConceptSpecializationExpr. The above reproducer works perfectly with it.

@erichkeane
Copy link
Collaborator Author

Put up a review here to have the code-owner take a look: https://reviews.llvm.org/D136451 but others are welcome to it as well.

@erichkeane
Copy link
Collaborator Author

https://reviews.llvm.org/D136451 committed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" concepts C++20 concepts crash Prefer [crash-on-valid] or [crash-on-invalid]
Projects
Status: No status
Development

No branches or pull requests

4 participants