diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 748e2db2f8507..43ea6a3ffd6e6 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -789,6 +789,9 @@ Bug Fixes to C++ Support Fixes: (`#68769 `_) +- Fixed a crash for C++98/03 while checking an ill-formed ``_Static_assert`` expression. + Fixes: (`#72025 `_) + - Clang now defers the instantiation of explicit specifier until constraint checking completes (except deduction guides). Fixes: (`#59827 `_) diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 2aafe5bd5289f..986302e1fd225 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -8618,7 +8618,7 @@ bool LValueExprEvaluator::VisitMaterializeTemporaryExpr( Result.set(E); } else { Value = &Info.CurrentCall->createTemporary( - E, E->getType(), + E, Inner->getType(), E->getStorageDuration() == SD_FullExpression ? ScopeKind::FullExpression : ScopeKind::Block, Result); diff --git a/clang/test/SemaCXX/pr72025.cpp b/clang/test/SemaCXX/pr72025.cpp new file mode 100644 index 0000000000000..9f0a4b0f43630 --- /dev/null +++ b/clang/test/SemaCXX/pr72025.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -verify -std=c++03 -fsyntax-only %s +struct V { + char c[2]; + banana V() : c("i") {} // expected-error {{unknown type name}} + // expected-error@-1 {{constructor cannot have a return type}} +}; + +_Static_assert(V().c[0], ""); // expected-error {{is not an integral constant expression}} +