1 // { dg-do assemble } 2 // GROUPS passed initialization 3 class foo { 4 public: 5 int data; foo(int dat)6 foo(int dat) { data = dat; } 7 }; 8 9 class bar { 10 public: 11 foo f[3] = { 1, 2, 3 }; // works: f[0] = 1, f[1] = 2, f[2] = 3 // { dg-error "" } ANSI C++ forbids initialization of member f; 12 }; 13 14 class bar2 { 15 public: 16 foo f[3] = { foo(1), foo(2), foo(3) }; // { dg-error "" } ANSI C++ forbids initialization of member f; 17 // does not compile -- error: field initializer is not constant 18 }; 19 main(void)20int main(void) 21 { 22 foo f[3] = { foo(1), foo(2), foo(3) }; 23 // standard C++ ... and it works too! :) 24 return 0; 25 } 26