File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -2523,7 +2523,7 @@ bool Compiler<Emitter>::VisitCXXConstructExpr(const CXXConstructExpr *E) {
2523
2523
if (E->requiresZeroInitialization ()) {
2524
2524
const Record *R = getRecord (E->getType ());
2525
2525
2526
- if (!this ->visitZeroRecordInitializer (R, E))
2526
+ if (!R-> isUnion () && ! this ->visitZeroRecordInitializer (R, E))
2527
2527
return false ;
2528
2528
2529
2529
// If the constructor is trivial anyway, we're done.
Original file line number Diff line number Diff line change @@ -253,4 +253,19 @@ namespace Nested {
253
253
// both-note {{in call to}}
254
254
255
255
}
256
+
257
+
258
+ namespace Zeroing {
259
+ struct non_trivial_constructor {
260
+ constexpr non_trivial_constructor () : x(100 ) {}
261
+ int x;
262
+ };
263
+ union U2 {
264
+ int a{1000 };
265
+ non_trivial_constructor b;
266
+ };
267
+
268
+ static_assert (U2().b.x == 100 , " " ); // both-error {{not an integral constant expression}} \
269
+ // both-note {{read of member 'b' of union with active member 'a'}}
270
+ }
256
271
#endif
You can’t perform that action at this time.
0 commit comments