ojhunt wrote:

@mizvekov @cor3ntin ok, I think the actual issue is in 
`Sema::PushExpressionEvaluationContext`. When pushing a new evaluation context 
down we all set the new context's `InDiscardedStatement` state to its parent's 
state.

I think for lambda expressions that is incorrect as it means the body of the 
lambda is instantiated as if it is an a discarded context, so as @mizvekov 
explained to me, all the return statements are considered discarded and the 
instantiation is then deduced as having a void return type.

My very quick testing (just filtering that assignment on the lambda context not 
being null - which is correct enough to test, but I think is not correct in a 
number of cases like template args, and similar?) appears to have correct 
behavior on the new test cases, and doesn't seem to break any existing tests. 
But I'm concerned that's a lack of coverage as I'm not sure when in the 
instantiation process we're actually pushing this context down, and I'm 
similarly not sure what the context for different parts of the overall lambda 
expression, ie:

```cpp
auto f = [expressions here might be considered discarded?](auto foo = <another 
expression> ) requires ( and again ) {
   and now we're in the definitely not discarded bit
}
```


https://github.com/llvm/llvm-project/pull/153921
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to