[clang] [clang][c23] Avoid assertion on an invalid static constexpr variable (PR #175927)
Shafik Yaghmour via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 14 13:28:07 PST 2026
================
@@ -14122,7 +14122,10 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) {
// C99 6.7.8p4: All the expressions in an initializer for an object that has
// static storage duration shall be constant expressions or string literals.
} else if (VDecl->getStorageClass() == SC_Static) {
- CheckForConstantInitializer(Init);
+ // Avoid evaluating the initializer twice for constexpr variables. It will
+ // be evaluated later.
----------------
shafik wrote:
Does it make sense to point out where it will be done later?
https://github.com/llvm/llvm-project/pull/175927
More information about the cfe-commits
mailing list