diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -5142,8 +5142,11 @@ case Stmt::ReturnStmtClass: { const Expr *RetExpr = cast(S)->getRetValue(); FullExpressionRAII Scope(Info); - if (RetExpr && RetExpr->isValueDependent()) - return EvaluateDependentExpr(RetExpr, Info) ? ESR_Returned : ESR_Failed; + if (RetExpr && RetExpr->isValueDependent()) { + EvaluateDependentExpr(RetExpr, Info); + // We know we returned, but we don't know what the value is. + return ESR_Failed; + } if (RetExpr && !(Result.Slot ? EvaluateInPlace(Result.Value, Info, *Result.Slot, RetExpr) diff --git a/clang/test/SemaCXX/constexpr-function-recovery-crash.cpp b/clang/test/SemaCXX/constexpr-function-recovery-crash.cpp --- a/clang/test/SemaCXX/constexpr-function-recovery-crash.cpp +++ b/clang/test/SemaCXX/constexpr-function-recovery-crash.cpp @@ -66,3 +66,6 @@ constexpr int test9(int x) { return f<1>(f(1)); // expected-error {{no matching function for call to 'f'}} } + +constexpr int test10() { return undef(); } // expected-error {{use of undeclared identifier 'undef'}} +static_assert(test10() <= 1, "should not crash"); // expected-error {{static_assert expression is not an integral constant expression}}