OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [g++.old-deja/] [g++.law/] [init1.C] - Rev 305

Compare with Previous | Blame | View Log

// { dg-do assemble  }
// GROUPS passed initialization
class foo {
public:
  int data;
  foo(int dat) { data = dat; }
};

class bar {
public:
  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;
};

class bar2 {
public:
      foo f[3] = { foo(1), foo(2), foo(3) }; // { dg-error "" } ANSI C++ forbids initialization of member f;
  // does not compile -- error: field initializer is not constant
};

int main(void)
{
  foo f[3] = { foo(1), foo(2), foo(3) };
  // standard C++ ... and it works too! :)
  return 0;
}

Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.