[Bug c++/63707] New: Brace initialization of array sometimes fails if no copy constructor
john.lindgren at aol dot com
gcc-bugzilla@gcc.gnu.org
Sat Nov 1 18:44:00 GMT 2014
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63707
Bug ID: 63707
Summary: Brace initialization of array sometimes fails if no
copy constructor
Product: gcc
Version: 4.9.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: john.lindgren at aol dot com
Created attachment 33859
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33859&action=edit
Test case 1
Brace-initializing an array of a class without a public copy constructor gives
an error in some cases but succeeds in others. After discussing the problem
here [1], I believe this is bug in GCC.
Attached are three test cases:
test1-fails.cc: Initialization of member array of non-literal type (error)
test2-works.cc: Initialization of member array of literal type (compiles)
test3-works.cc: Initialization of static array of non-literal type (compiles)
test4-works.cc: Initialization of single member of non-literal type (compiles)
The error given is:
$ g++ -Wall -Wextra -std=c++11 -c test1-fails.cc
test1-fails.cc: In constructor ‘Parent::Parent()’:
test1-fails.cc:13:35: error: use of deleted function ‘Child::Child(const
Child&)’
Parent () : children {{5}, {7}} {}
^
test1-fails.cc:7:5: note: declared here
Child (const Child &) = delete;
^
$ g++ --version
g++ (GCC) 4.9.1 20140903 (prerelease)
By way of comparison, Clang 3.5.0 compiles all three test cases without errors.
[1]
http://stackoverflow.com/questions/26685551/how-to-initialize-array-of-classes-with-deleted-copy-constructor-c11
More information about the Gcc-bugs
mailing list