1 // { dg-do compile { target c++11 } } 2 // { dg-additional-options { -Wno-pedantic } } 3 // PR c++/79118 failure to check initialization of anonymous members. 4 5 struct One 6 { 7 union 8 { 9 int a; 10 int b; 11 }; 12 OneOne13 constexpr One () : a(), b() {} // { dg-error "multiple" } OneOne14 constexpr One (int) : a() {} OneOne15 constexpr One (unsigned) : b () {} OneOne16 constexpr One (void *) {} // { dg-error "exactly one" "" { target c++17_down } } 17 }; 18 19 One a (); 20 One b (0); 21 One c (0u); 22 One d ((void *)0); 23 24 struct Two 25 { 26 struct 27 { 28 int a; 29 int b; 30 }; 31 TwoTwo32 constexpr Two () : a(), b() {} TwoTwo33 constexpr Two (int) : a() {} // { dg-error "b' must be initialized" "" { target c++17_down } } TwoTwo34 constexpr Two (unsigned) : b () {} // { dg-error "a' must be initialized" "" { target c++17_down } } TwoTwo35 constexpr Two (void *) {} // { dg-error "a' must be initialized" "" { target c++17_down } } 36 // { dg-error "b' must be initialized" "" { target c++17_down } .-1 } 37 }; 38 39 Two e (); 40 Two f (0); 41 Two g (0u); 42 Two h ((void *)0); 43