Skip to content

Crash in frontend when trying examples of P2564R3 (propagating consteval) #82258

Closed
@loic-joly-sonarsource

Description

@loic-joly-sonarsource

Link to compiler explorer reproducer: https://godbolt.org/z/Gnr3bbnej

The following code, extracted from P2564R3 (consteval needs to propagate up), crashed the frontend:

static_assert(none_of(
    types,
    []{
        return is_invalid;
    }()
));

Excerpt from the call stack:

 #4 0x0000000000b0c48a clang::Sema::MarkExpressionAsImmediateEscalating(clang::Expr*) (.cold) SemaExpr.cpp:0:0
 #5 0x0000000006280f7d clang::Sema::PopExpressionEvaluationContext() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6280f7d)
 #6 0x000000000646e5d2 clang::Sema::BuildLambdaExpr(clang::SourceLocation, clang::SourceLocation, clang::sema::LambdaScopeInfo*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x646e5d2)
 #7 0x0000000006472b61 clang::Sema::ActOnLambdaExpr(clang::SourceLocation, clang::Stmt*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6472b61)
 #8 0x0000000005d79ed7 clang::Parser::ParseLambdaExpressionAfterIntroducer(clang::LambdaIntroducer&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5d79ed7)
 #9 0x0000000005d7b8ab clang::Parser::ParseLambdaExpression() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5d7b8ab)
#10 0x0000000005d58dcb clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5d58dcb)
#11 0x0000000005d5a76a clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, clang::Parser::TypeCastState, bool, bool*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5d5a76a)

Additionally, the following similar code, which is supposed to work, does not crash but fails to compile:

static_assert(none_of(
    types,
    +[](info i) consteval {
        return is_invalid(i);
    }
));

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"crashPrefer [crash-on-valid] or [crash-on-invalid]

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions