1 // PR c++/91353 - P1331R2: Allow trivial default init in constexpr contexts. 2 // { dg-do compile { target c++20 } } 3 4 // This bullet in [dcl.constexpr] is now gone: 5 // - every non-static data member and base class sub-object shall be initialized 6 7 struct A { 8 int i; AA9 constexpr A(int _i) { i = _i; } 10 }; 11 12 struct B { 13 int i; BB14 constexpr B() { } 15 }; 16 17 // Anonymous members. 18 struct E { 19 int a; 20 union { 21 char b; 22 __extension__ struct { 23 double c; 24 long d; 25 }; 26 union { 27 char e; 28 void *f; 29 }; 30 }; 31 __extension__ struct { 32 long long g; 33 __extension__ struct { 34 int h; 35 double i; 36 }; 37 union { 38 char *j; 39 E *k; 40 }; 41 }; 42 43 // Completely initialized. EE44 constexpr E(int(&)[1]) : a(), b(), g(), h(), i(), j() {} EE45 constexpr E(int(&)[3]) : a(), e(), g(), h(), i(), k() {} EE46 constexpr E(int(&)[7]) : a(), b(), g(), h(), i(), j() {} EE47 constexpr E(int(&)[8]) : a(), f(), g(), h(), i(), k() {} EE48 constexpr E(int(&)[9]) : a(), c(), d(), g(), h(), i(), k() {} 49 50 // Missing d, i, j/k union init. EE51 constexpr E(int(&)[2]) : a(), c(), g(), h() {} 52 53 // Missing h, j/k union init. EE54 constexpr E(int(&)[4]) : a(), c(), d(), g(), i() {} 55 56 // Missing b/c/d/e/f union init. EE57 constexpr E(int(&)[5]) : a(), g(), h(), i(), k() {} 58 59 // Missing a, b/c/d/e/f union, g/h/i/j/k struct init. EE60 constexpr E(int(&)[6]) {} 61 }; 62