Bug 45418 - [C++0x] can't initialize array of non-trivial type with brace-init
Summary: [C++0x] can't initialize array of non-trivial type with brace-init
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: 4.6.1
Assignee: Jason Merrill
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-26 13:51 UTC by Marc Glisse
Modified: 2011-05-25 15:28 UTC (History)
3 users (show)

See Also:
Host: x86_64-linux-gnu
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-05-25 04:46:01


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Glisse 2010-08-26 13:51:16 UTC
Hello,

this may just not be implemented yet, but in case it was missed:

struct A1 {
};
struct A2 {
        A2(){}
};

template <class T> struct B {
        T tab[1];
        B(T const& t):tab({t}) {} // here
};

int main(){
        int i=2;
        B<int> b{i};
        A1 a1;
        B<A1> e1{a1};
        A2 a2;
        A2 c[1]{{a2}};
        B<A2> e2{a2}; // fails
}

complains about a "bad array initializer", whereas with a trivial type A1 or a builtin int, it works fine.
Comment 1 Jason Merrill 2011-05-25 14:35:12 UTC
Author: jason
Date: Wed May 25 14:35:09 2011
New Revision: 174204

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174204
Log:
	PR c++/45418
	* init.c (perform_member_init): Handle list-initialization
	of array of non-trivial class type.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/initlist50.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/init.c
    trunk/gcc/testsuite/ChangeLog
Comment 2 Jason Merrill 2011-05-25 15:26:37 UTC
Author: jason
Date: Wed May 25 15:26:33 2011
New Revision: 174209

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174209
Log:
	PR c++/45418
	* init.c (perform_member_init): Handle list-initialization
	of array of non-trivial class type.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/g++.dg/cpp0x/initlist50.C
Modified:
    branches/gcc-4_6-branch/gcc/cp/ChangeLog
    branches/gcc-4_6-branch/gcc/cp/init.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
Comment 3 Jason Merrill 2011-05-25 15:28:30 UTC
Fixed for 4.6.1.