[Bug c++/39056] [4.4 regression] [c++0x] ICE with invalid initializer list for complex variable
--- Comment #3 from jakub at gcc dot gnu dot org 2009-02-03 17:23 --- Subject: Bug 39056 Author: jakub Date: Tue Feb 3 17:23:11 2009 New Revision: 143899 URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=143899 Log: PR c++/39056 * typeck2.c (digest_init_r): Don't call process_init_constructor for COMPLEX_TYPE. * g++.dg/cpp0x/initlist13.C: New test. Added: trunk/gcc/testsuite/g++.dg/cpp0x/initlist13.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/typeck2.c trunk/gcc/testsuite/ChangeLog -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39056
[Bug c++/39056] [4.4 regression] [c++0x] ICE with invalid initializer list for complex variable
--- Comment #4 from jakub at gcc dot gnu dot org 2009-02-03 19:31 --- Fixed. -- jakub at gcc dot gnu dot org changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution||FIXED http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39056
[Bug c++/39056] [4.4 regression] [c++0x] ICE with invalid initializer list for complex variable
--- Comment #5 from bkoz at gcc dot gnu dot org 2009-02-03 23:47 --- Benjamin, does you have an opinion about initializer-lists and complex? I guess the library complex class will accept { real, imag } naturally because it has a suitable constructor. It would be great if this stuff matched for C/C++. #include complex std::complexdouble z1{1.1, 2.2}; std::complexdouble z2{3.3}; std::complexdouble z3{ }; all work with -std=gnu++0x, but not with -std=c++98. So, direct list init works for C++ std::complex. All forms of copy-list init fail for std::complex though. std::complexdouble z4 = {1.1, 2.2}; std::complexdouble z5 = {3.3}; std::complexdouble z6 = { }; complex_init.cc:9: error: call of overloaded complex(brace-enclosed initializer list) is ambiguous /mnt/share/bld/gcc/x86_64-unknown-linux-gnu/libstdc++-v3/include/complex:1174: note: candidates are: std::complexdouble::complex(const std::complexfloat) /mnt/share/bld/gcc/x86_64-unknown-linux-gnu/libstdc++-v3/include/complex:1162: note: std::complexdouble::complex(const std::complexdouble) There seems to be some inconsistency in the way this is defined, will bring up on libstdc++-ml/LWG. The original testcase: __complex__ int i({0}); fails in the C++ version: std::complexdouble i({0}); So that part is consistent. -benjamin -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39056
[Bug c++/39056] [4.4 regression] [c++0x] ICE with invalid initializer list for complex variable
--- Comment #6 from bkoz at gcc dot gnu dot org 2009-02-03 23:47 --- Created an attachment (id=17240) -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17240action=view) test std::complex, __complex init -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39056
[Bug c++/39056] [4.4 regression] [c++0x] ICE with invalid initializer list for complex variable
--- Comment #1 from jakub at gcc dot gnu dot org 2009-02-02 11:18 --- I think this depends on whether we want as an exception allow this or not. If not, e.g.: --- typeck2.c.jj22009-01-13 18:32:14.0 +0100 +++ typeck2.c2009-02-02 12:15:58.0 +0100 @@ -789,7 +789,8 @@ digest_init_r (tree type, tree init, boo } /* Handle scalar types (including conversions) and references. */ - if (TREE_CODE (type) != COMPLEX_TYPE + if ((TREE_CODE (type) != COMPLEX_TYPE + || BRACE_ENCLOSED_INITIALIZER_P (init)) (SCALAR_TYPE_P (type) || code == REFERENCE_TYPE)) { tree *exp; gets rid of the ICE, instead it will reject it with: pr39056.C:1: error: cannot convert 'brace-enclosed initializer list' to 'int __complex__' in initialization -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39056
[Bug c++/39056] [4.4 regression] [c++0x] ICE with invalid initializer list for complex variable
--- Comment #2 from jason at gcc dot gnu dot org 2009-02-02 19:02 --- Jakub's patch looks fine to me. Benjamin, does you have an opinion about initializer-lists and complex? I guess the library complex class will accept { real, imag } naturally because it has a suitable constructor. Note that initialization with = { 0 } still works normally, and = { 0, 0 } is still rejected as having too many initializers for a scalar, like in C. -- jason at gcc dot gnu dot org changed: What|Removed |Added CC||bkoz at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39056
[Bug c++/39056] [4.4 regression] [c++0x] ICE with invalid initializer list for complex variable
-- rguenth at gcc dot gnu dot org changed: What|Removed |Added Priority|P3 |P2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39056
[Bug c++/39056] [4.4 regression] [c++0x] ICE with invalid initializer list for complex variable
-- reichelt at gcc dot gnu dot org changed: What|Removed |Added Target Milestone|--- |4.4.0 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39056