================ @@ -1392,7 +1392,8 @@ class CXXRecordDecl : public RecordDecl { bool allowConstDefaultInit() const { return !data().HasUninitializedFields || !(data().HasDefaultedDefaultConstructor || - needsImplicitDefaultConstructor()); + needsImplicitDefaultConstructor()) || + hasInClassInitializer(); ---------------- zygoloid wrote:
I don't think so. Maybe we can change the behavior of `HasUninitializedFields` -- it only exists to support this check, so we can change it to do whatever this check needs. What I'm thinking is: * If the class is not a union, then proceed as we currently do: start it off as `false` and set it to `true` if we find an uninitialized field. * If the class is a union, then do the opposite: start it off as `true` and set it to `false` if we find an initialized field. (So for a non-union, the field is true if all fields are const default initializable, and for a union, the field is true if *any* field is const default initializable.) Then I think the only change we'd need here would be to also treat empty unions as const default initializable. https://github.com/llvm/llvm-project/pull/96301 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits