[clang] [Clang] Implement P3074R7: trivial unions (C++26) (PR #185886)

Corentin Jabot via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 8 01:00:00 PDT 2026


================
@@ -1180,7 +1180,11 @@ void CXXRecordDecl::addedMember(Decl *D) {
       // C++11 [class]p5:
       //   A default constructor is trivial if [...] no non-static data member
       //   of its class has a brace-or-equal-initializer.
-      data().HasTrivialSpecialMembers &= ~SMF_DefaultConstructor;
+      // P3074R7 [class.default.ctor]p3:
+      //   In C++26, a union's default constructor is always trivial,
+      //   even with brace-or-equal-initializers.
----------------
cor3ntin wrote:

This should quote the actual wording

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


More information about the cfe-commits mailing list