-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[clang] Crash when calling object of type obtained from lambda in unevaluated context #76674
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
@llvm/issue-subscribers-clang-codegen Author: None (MagentaTreehouse)
The following C++20 code causes a crash on clang 17:
```cpp
template <class>
struct A {
template <class U>
using Func = decltype([] {return U{};});
};
A<int>::Func<int> f{};
clang++: /root/llvm-project/clang/lib/AST/Decl.cpp:2503: clang::APValue* clang::VarDecl::evaluateValueImpl(llvm::SmallVectorImpl<std::pair<clang::SourceLocation, clang::PartialDiagnostic> >&, bool) const: Assertion `!Init->isValueDependent()' failed.
|
Looks like a similar to: #23317 but in the later case the code is ill-formed. In this case it looks well-formed. So the underlying problem may be the same but potentially we could fix the later without fixing this one. |
This looks closer to a duplicate: #60432 |
It looks like we are not substituting the dependent lambda in the initialization of the variable. the equivalent code with the outer class template works fine |
…eclaration (#82310) This patch attempts to fix the lambda call expression inside of a type alias declaration from two aspects: 1. Defer the lambda call expression building until after we have sufficient template arguments. This avoids the overeager (and often wrong) semantic checking before the type alias instantiation. 2. Properly obtain template arguments involving a template type alias for constraint checking. It is unfortunate that a `TypeAliasTemplateDecl` (or a `TypeAliasDecl`) is never a `DeclContext`, nor does it have an associated specialization Decl from which we could collect these template arguments. Thus, I added a new CodeSynthesisContext to record template arguments for alias declarations. Fixes #70601 Fixes #76674 Fixes #79555 Fixes #81145 Fixes #82104 Note that this doesn't involve the fix for #28461. That seems different, and I'd like to leave it as a follow-up.
@llvm/issue-subscribers-clang-frontend Author: None (MagentaTreehouse)
The following C++20 code causes a crash on clang 17:
```cpp
template <class>
struct A {
template <class U>
using Func = decltype([] {return U{};});
};
A<int>::Func<int> f{};
clang++: /root/llvm-project/clang/lib/AST/Decl.cpp:2503: clang::APValue* clang::VarDecl::evaluateValueImpl(llvm::SmallVectorImpl<std::pair<clang::SourceLocation, clang::PartialDiagnostic> >&, bool) const: Assertion `!Init->isValueDependent()' failed.
|
The following C++20 code causes a crash on clang 17:
Compiler Explorer: https://godbolt.org/z/74q87Kfjf
Compiler output:
The text was updated successfully, but these errors were encountered: