-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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] ICE on handling reference to consteval function in initializer #66562
Comments
CC @cor3ntin |
@llvm/issue-subscribers-clang-frontend
```cpp
namespace ns
{
consteval int foo(int x) { return 1; }
}
template <class A>
Stack dump:
<source>:9:32: error: cannot take address of consteval function 'foo' outside of an immediate invocation
Actions.ExprEvalContexts.back().InImmediateEscalatingFunctionContext = true;
|
crash with
https://godbolt.org/z/5a8hPo5je
On Clang 16, this used to error out with :
I think the problem stems from
1/ during the parsing of the initializer, the ExpressionEvaluationContext is not set to ConstantEvaluated, so the reference to ns::foo is added to ReferenceToConsteval
2/ When popping the Sema::PopExpressionEvalContext is called,
Context.InImmediateEscalatingFunctionContext
is true, most likely becauseParseCXXMemberInitializer
contains this line :Which does not makes a lot of sense to me (besides this kind of state mutation would be more suitable on the Sema side? e.g. in Sema::ActOnStartCXXInClassMemberInitializer/Finish).
Finally, the evaluation context should probably be set to ConstantEvaluated when the variable is
constexpr
to not error on the declaration reference.The text was updated successfully, but these errors were encountered: