[clang] [clang] Allow class with anonymous union member to be const-default-constructible even if a union member has a default member initializer (#95854) (PR #96301)

via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 27 01:16:01 PDT 2024


================
@@ -1125,7 +1128,11 @@ void CXXRecordDecl::addedMember(Decl *D) {
         data().DefaultedCopyConstructorIsDeleted = true;
     }
 
-    if (!Field->hasInClassInitializer() && !Field->isMutable()) {
+    if (isUnion() && !Field->isMutable()) {
+      if (Field->hasInClassInitializer()) {
+        data().HasUninitializedFields = false;
+      }
----------------
cor3ntin wrote:

```suggestion
      if (Field->hasInClassInitializer())
        data().HasUninitializedFields = false;
```

https://github.com/llvm/llvm-project/pull/96301


More information about the cfe-commits mailing list