Consider: struct Foo { Foo(); // comment out -> g++ fails with "error: invalid initializer" };
void fn() { Foo f[2]; Foo g[2] = f; } The test above is accepted by g++ (tried 3.4.6, 4.0.0, 4.1.1 and 4.2-20060902). EDG fails with: $ edgcpfe pp.cpp "pp.cpp", line 8: error: initialization with "{...}" expected for aggregate object Foo g[2] = f; ^ 1 error detected in the compilation of "pp.cpp". Here is the original test case (also accepted by all versions of g++): template <class T, class U> struct pair { pair(const T& t, const U& u) : first(t), second(u) { } T first; U second; }; struct Foo { Foo(); // comment out -> g++ fails with // "error: ISO C++ forbids assignment of arrays" }; int main() { Foo f[2]; pair<int, Foo[2]> p (1, f); return 0; } And analysis of it by William M. (Mike) Miller | Edison Design Group, Inc.: > Could you please confirm that this is a g++ bug? Yes, it's a bug. The Standard (12.6.2 paragraph 3) defines an initialization like "second(u)" to be direct-initialization as described in section 8.5. Section 8.5 paragraph 14 says that initialization of an array object is handled in section 8.5.1. However, 8.5.1 does not provide for any way of initializing an array from another array (except for the special case of a string literal, 8.5.2). Arrays can only be initialized to a value using the brace notation, which is not permitted in a mem-initializer. -- Summary: Illegal array initialization accepted Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ppluzhnikov at charter dot net GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28956