public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/39056] New: [4.4 regression] [c++0x] ICE with invalid initializer list for complex variable
@ 2009-02-01 10:23 reichelt at gcc dot gnu dot org
2009-02-01 10:24 ` [Bug c++/39056] " reichelt at gcc dot gnu dot org
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2009-02-01 10:23 UTC (permalink / raw)
To: gcc-bugs
The following invalid code snippet triggers an ICE on the trunk:
==============================
__complex__ int i({0});
==============================
bug.cc:1: internal compiler error: in process_init_constructor, at
cp/typeck2.c:1192
Please submit a full bug report, [etc.]
The bug appeared with the introduction of initializer lists:
2008-07-02 Jason Merrill <jason@redhat.com>
* Make-lang.in (cp/typeck2.o): Add $(REAL_H) dependency.
Implement WG21 N2672, Initializer List proposed wording
* cp-tree.h (enum cp_tree_index): Add CPTI_INIT_LIST_TYPE.
(struct lang_type_class): Add has_list_ctor bitfield.
(TYPE_HAS_LIST_CTOR): New macro.
(BRACE_ENCLOSED_INITIALIZER_P): Expect init_list_type_node.
...
It's a regression since the same code snippet didn't cause a crash before.
--
Summary: [4.4 regression] [c++0x] ICE with invalid initializer
list for complex variable
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Keywords: ice-on-invalid-code, monitored
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: reichelt at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39056
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/39056] [4.4 regression] [c++0x] ICE with invalid initializer list for complex variable
2009-02-01 10:23 [Bug c++/39056] New: [4.4 regression] [c++0x] ICE with invalid initializer list for complex variable reichelt at gcc dot gnu dot org
@ 2009-02-01 10:24 ` reichelt at gcc dot gnu dot org
2009-02-01 11:00 ` rguenth at gcc dot gnu dot org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2009-02-01 10:24 UTC (permalink / raw)
To: gcc-bugs
--
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/39056] [4.4 regression] [c++0x] ICE with invalid initializer list for complex variable
2009-02-01 10:23 [Bug c++/39056] New: [4.4 regression] [c++0x] ICE with invalid initializer list for complex variable reichelt at gcc dot gnu dot org
2009-02-01 10:24 ` [Bug c++/39056] " reichelt at gcc dot gnu dot org
@ 2009-02-01 11:00 ` rguenth at gcc dot gnu dot org
2009-02-02 11:18 ` jakub at gcc dot gnu dot org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-02-01 11:00 UTC (permalink / raw)
To: gcc-bugs
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39056
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/39056] [4.4 regression] [c++0x] ICE with invalid initializer list for complex variable
2009-02-01 10:23 [Bug c++/39056] New: [4.4 regression] [c++0x] ICE with invalid initializer list for complex variable reichelt at gcc dot gnu dot org
2009-02-01 10:24 ` [Bug c++/39056] " reichelt at gcc dot gnu dot org
2009-02-01 11:00 ` rguenth at gcc dot gnu dot org
@ 2009-02-02 11:18 ` jakub at gcc dot gnu dot org
2009-02-02 19:02 ` jason at gcc dot gnu dot org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu dot org @ 2009-02-02 11:18 UTC (permalink / raw)
To: gcc-bugs
------- 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.000000000 +0100
+++ typeck2.c2009-02-02 12:15:58.000000000 +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
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/39056] [4.4 regression] [c++0x] ICE with invalid initializer list for complex variable
2009-02-01 10:23 [Bug c++/39056] New: [4.4 regression] [c++0x] ICE with invalid initializer list for complex variable reichelt at gcc dot gnu dot org
` (2 preceding siblings ...)
2009-02-02 11:18 ` jakub at gcc dot gnu dot org
@ 2009-02-02 19:02 ` jason at gcc dot gnu dot org
2009-02-03 17:23 ` jakub at gcc dot gnu dot org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-02-02 19:02 UTC (permalink / raw)
To: gcc-bugs
------- 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
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/39056] [4.4 regression] [c++0x] ICE with invalid initializer list for complex variable
2009-02-01 10:23 [Bug c++/39056] New: [4.4 regression] [c++0x] ICE with invalid initializer list for complex variable reichelt at gcc dot gnu dot org
` (3 preceding siblings ...)
2009-02-02 19:02 ` jason at gcc dot gnu dot org
@ 2009-02-03 17:23 ` jakub at gcc dot gnu dot org
2009-02-03 19:31 ` jakub at gcc dot gnu dot org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu dot org @ 2009-02-03 17:23 UTC (permalink / raw)
To: gcc-bugs
------- 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=gcc&view=rev&rev=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
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/39056] [4.4 regression] [c++0x] ICE with invalid initializer list for complex variable
2009-02-01 10:23 [Bug c++/39056] New: [4.4 regression] [c++0x] ICE with invalid initializer list for complex variable reichelt at gcc dot gnu dot org
` (4 preceding siblings ...)
2009-02-03 17:23 ` jakub at gcc dot gnu dot org
@ 2009-02-03 19:31 ` jakub at gcc dot gnu dot org
2009-02-03 23:47 ` bkoz at gcc dot gnu dot org
2009-02-03 23:47 ` bkoz at gcc dot gnu dot org
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu dot org @ 2009-02-03 19:31 UTC (permalink / raw)
To: gcc-bugs
------- 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
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/39056] [4.4 regression] [c++0x] ICE with invalid initializer list for complex variable
2009-02-01 10:23 [Bug c++/39056] New: [4.4 regression] [c++0x] ICE with invalid initializer list for complex variable reichelt at gcc dot gnu dot org
` (5 preceding siblings ...)
2009-02-03 19:31 ` jakub at gcc dot gnu dot org
@ 2009-02-03 23:47 ` bkoz at gcc dot gnu dot org
2009-02-03 23:47 ` bkoz at gcc dot gnu dot org
7 siblings, 0 replies; 9+ messages in thread
From: bkoz at gcc dot gnu dot org @ 2009-02-03 23:47 UTC (permalink / raw)
To: gcc-bugs
------- 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=17240&action=view)
test std::complex, __complex init
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39056
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/39056] [4.4 regression] [c++0x] ICE with invalid initializer list for complex variable
2009-02-01 10:23 [Bug c++/39056] New: [4.4 regression] [c++0x] ICE with invalid initializer list for complex variable reichelt at gcc dot gnu dot org
` (6 preceding siblings ...)
2009-02-03 23:47 ` bkoz at gcc dot gnu dot org
@ 2009-02-03 23:47 ` bkoz at gcc dot gnu dot org
7 siblings, 0 replies; 9+ messages in thread
From: bkoz at gcc dot gnu dot org @ 2009-02-03 23:47 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1432 bytes --]
------- 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::complex<double> z1{1.1, 2.2};
std::complex<double> z2{3.3};
std::complex<double> 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::complex<double> z4 = {1.1, 2.2};
std::complex<double> z5 = {3.3};
std::complex<double> 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::complex<double>::complex(const std::complex<float>&)
/mnt/share/bld/gcc/x86_64-unknown-linux-gnu/libstdc++-v3/include/complex:1162:
note: std::complex<double>::complex(const
std::complex<double>&)
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::complex<double> i({0});
So that part is consistent.
-benjamin
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39056
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2009-02-03 23:47 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-01 10:23 [Bug c++/39056] New: [4.4 regression] [c++0x] ICE with invalid initializer list for complex variable reichelt at gcc dot gnu dot org
2009-02-01 10:24 ` [Bug c++/39056] " reichelt at gcc dot gnu dot org
2009-02-01 11:00 ` rguenth at gcc dot gnu dot org
2009-02-02 11:18 ` jakub at gcc dot gnu dot org
2009-02-02 19:02 ` jason at gcc dot gnu dot org
2009-02-03 17:23 ` jakub at gcc dot gnu dot org
2009-02-03 19:31 ` jakub at gcc dot gnu dot org
2009-02-03 23:47 ` bkoz at gcc dot gnu dot org
2009-02-03 23:47 ` bkoz at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).