[PATCH] D23385: Implement __attribute__((require_constant_initialization)) for safe static initialization.
Eric Fiselier via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 15 17:14:47 PDT 2016
EricWF added inline comments.
================
Comment at: lib/Sema/SemaDecl.cpp:10519-10520
@@ +10518,4 @@
+ auto *CE = dyn_cast<CXXConstructExpr>(Init);
+ bool DiagErr = (var->isInitKnownICE() || (CE && CE->getConstructor()->isConstexpr()))
+ ? !var->checkInitIsICE() : !checkConstInit();
+ if (DiagErr)
----------------
rsmith wrote:
> In C++11 onwards, `checkInitIsICE` is the right thing to use in all cases. In C++98, `checkInitIsICE` is appropriate for globals of integral type; we do not have an implementation of strict constant expression checking for other types. Perhaps just documenting that (and maybe adding a FIXME here) is the best you can do for now, assuming you're not interested in implementing the C++98 rules.
SGTM. I think I'll fall back to `isConstantInitializer()` in C++03. Do you have an example of what `checkConstantInitializer()` gets wrong in C++03?
https://reviews.llvm.org/D23385
More information about the cfe-commits
mailing list