fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. struct A { int x; int y; int z; };
  6. A a{.y = 2, .x = 1}; // error; designator order does not match declaration order
  7. A b{.x = 1, .z = 2}; // ok, b.y initialized to 0
  8.  
  9. return 0;
  10. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:6:23: error: designator order for field ‘main()::A::x’ does not match declaration order in ‘main()::A’
     A a{.y = 2, .x = 1}; // error; designator order does not match declaration order
                       ^
stdout
Standard output is empty