Issue 145776
Summary [Clang] Immediate-escalating _expression_ attributed to wrong lambda
Labels clang
Assignees
Reporter katzdm
    The following should be well-formed, but [clang diagnoses](https://godbolt.org/z/57xfWbE71):

```cpp
void runtime_only() { }
consteval void comptime_only() {}

void fn() {
    []() {
 runtime_only();
        [](){ (void) comptime_only; }();
 }();
}
```

The _id-expression_ that names `comptime_only` is [immediate-escalating](https://eel.is/c++draft/expr.const#25.1). Clang currently attributes that _expression_ to the outer lambda, despite its occurrence within the inner lambda. It seems to me that this stems from the `ExpressionEvaluationContext` corresponding to the inner lambda [being popped](https://github.com/llvm/llvm-project/blob/0c359d747daa97197d17d2c48d7964d49f7f1b98/clang/lib/Sema/SemaLambda.cpp#L2173) _after_ the `FunctionScopeInfo` corresponding to the same has [already been popped](https://github.com/llvm/llvm-project/blob/0c359d747daa97197d17d2c48d7964d49f7f1b98/clang/lib/Sema/SemaLambda.cpp#L1978). Naively re-sequencing these operations appears to cause other problems (e.g., failing assertions related to ODR-uses in `ActOnFinishFunctionBody`).
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to