Open philnik777 opened 2 weeks ago
@llvm/issue-subscribers-clang-frontend
Author: Nikolas Klauser (philnik777)
This is CWG1313. It's unclear to me whether CWG1313 should be treated as a patch to C++11 constant expression additions or C++98 rules.
The logic for this diagnostic lives in Sema::CheckCompleteVariableDeclaration()
, and the issue is that we get into if (!getLangOpts().CPlusPlus11 && !getLangOpts().C23) {
which sets HasConstInit
to true, and we wind up in if (HasConstInit) {
and not } else if (GlobalStorage && var->hasAttr<ConstInitAttr>()) {
.
The C++98 constant expression rules are very much like the C ones, and are almost entirely concerned only with the operations performed and not their semantics and the values involved. Given the rules are so different, I don't think it makes sense to apply CWG1313 retroactively.
Do we emit a dynamic initializer for the variable in question? That'd be a clear bug.
Do we emit a dynamic initializer for the variable in question? That'd be a clear bug.
No, we don't seem to, at least from my testing.
is accepted in C++03 but in no other dialect.