You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
consteval int here() { return 5; }
void error(int location = here()) { }
void bob () { error(); }
The problem here is we markused the consteval fn, which causes us to emit an error about taking the address of the consteval fn. I patched up EvaluatedExprMarker, called from Sema::CheckCXXDefaultArgExpr to skip such consteval calls, but we then ICE in code emission, trying to emit a consteval fn body.
https://bugs.llvm.org/show_bug.cgi?id=5810 seems relevant, as that's mentioned in the comment in CheckCXXDefaultArgExpr:
// FIXME: We should really be rebuilding the default argument with new
// bound temporaries; see the comment in PR5810.
// We don't need to do that with block decls, though, because
// blocks in default argument expression can never capture anything.
5810 includes the ominous note:
One could imagine rebuilding the AST nodes with new CXXTemporary pointers, although that's going to require a lot of code :(
Notice that because of __source_location(), which is different on every evaluation, we can't just morph the original defaultArgExpr as is held in the ParamDecl. We have to clone and evaluate at each use, I think.
(this default arg pattern is used in the source_location header to get the location corresponding to the caller of the source_location ctor, not the location of the ctor itself)
The text was updated successfully, but these errors were encountered:
It appears to be the same -- the problem doesn't just effect consteval ctors. The recent addition of builtin_source_location (https://reviews.llvm.org/rGd61487490022) seems to have exposed this issue -- suddenly the (gcc) libstdc++ source_location header bursts into light, and then goes down in flames :(
Consteval calls in default args do not work
The problem here is we markused the consteval fn, which causes us to emit an error about taking the address of the consteval fn. I patched up EvaluatedExprMarker, called from Sema::CheckCXXDefaultArgExpr to skip such consteval calls, but we then ICE in code emission, trying to emit a consteval fn body.
https://bugs.llvm.org/show_bug.cgi?id=5810 seems relevant, as that's mentioned in the comment in CheckCXXDefaultArgExpr:
// FIXME: We should really be rebuilding the default argument with new
// bound temporaries; see the comment in PR5810.
// We don't need to do that with block decls, though, because
// blocks in default argument expression can never capture anything.
5810 includes the ominous note:
One could imagine rebuilding the AST nodes with new CXXTemporary pointers, although that's going to require a lot of code :(
Notice that because of __source_location(), which is different on every evaluation, we can't just morph the original defaultArgExpr as is held in the ParamDecl. We have to clone and evaluate at each use, I think.
(this default arg pattern is used in the source_location header to get the location corresponding to the caller of the source_location ctor, not the location of the ctor itself)
The text was updated successfully, but these errors were encountered: