2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.law / init1.C
blob82f49ae24509aff6a4d6efd6098b99bc3697e136
1 // { dg-do assemble  }
2 // GROUPS passed initialization
3 class foo {
4 public:
5   int data;
6   foo(int dat) { data = dat; }
7 };
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;
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
20 int main(void)
22   foo f[3] = { foo(1), foo(2), foo(3) };
23   // standard C++ ... and it works too! :)
24   return 0;