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] Expansion of pack indexing expression that is a pack in a lambda triggers ICE #91885
Comments
@llvm/issue-subscribers-clang-frontend Author: A. Jiang (frederick-vs-ja)
It seems that some branches are missing for this case. [Godbolt link](https://godbolt.org/z/8YK9MGYdb).
```C++
#include <cstddef>
#include <utility>
void operate_one(auto&&) {} void operate_multi(auto&&...args) int main()
mangling a placeholder type
|
After reducing this example I get another ICE with a different crash report: void ICE(auto...args){
[&]<int idx>(){
using R = decltype( args...[idx] ) ;
}.template operator()<0>();
}
int main( ) {
ICE(1);
}
See https://godbolt.org/z/Ge5cbEM7e. Shall I open a new issue? |
It seems that the issue is related to the following function: llvm-project/clang/lib/AST/ComputeDependence.cpp Lines 367 to 380 in ad1a65f
Let's consider the following code snippets: void ICE(auto...args){
[&]<int idx>(){
using R = decltype( args...[idx] ) ;
}.template operator()<0>();
}
int main( ) {
ICE(1);
} When the transformation of substituting the template parameters of function Currently:
That's wrong since actually,
Then in: llvm-project/clang/lib/Sema/SemaType.cpp Lines 9739 to 9748 in ad1a65f
Since Possible fix: diff --git a/clang/lib/AST/ComputeDependence.cpp b/clang/lib/AST/ComputeDependence.cpp
index bad8e75b2f87..8d39431c889f 100644
--- a/clang/lib/AST/ComputeDependence.cpp
+++ b/clang/lib/AST/ComputeDependence.cpp
@@ -385,6 +385,10 @@ ExprDependence clang::computeDependence(PackIndexingExpr *E) {
std::optional<unsigned> Index = E->getSelectedIndex();
assert(Index && *Index < Exprs.size() && "pack index out of bound");
D |= Exprs[*Index]->getDependence();
+ } else {
+ /// non-empty PackIndexingExpr is type-dependent
+ /// if IndexExpr is instantiation-dependent
+ D |= ExprDependence::Type;
}
return D;
}
CC: @cor3ntin |
@RungeCC Thanks, that was exactly the issue :) |
Given `foo...[idx]` if idx is value dependent, the expression is type dependent. Fixes llvm#91885 Fixes llvm#91884
Given `foo...[idx]` if idx is value dependent, the expression is type dependent. Fixes llvm#91885 Fixes llvm#91884
…#91933) Given `foo...[idx]` if idx is value dependent, the expression is type dependent. Fixes llvm#91885 Fixes llvm#91884
It seems that some branches are missing for this case. Godbolt link.
The text was updated successfully, but these errors were encountered: