Bug 38698 - [4.4 regression] ICE initializing union with initializer list
Summary: [4.4 regression] ICE initializing union with initializer list
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.4.0
: P2 normal
Target Milestone: 4.4.0
Assignee: Jason Merrill
URL:
Keywords: ice-on-invalid-code, monitored
Depends on:
Blocks:
 
Reported: 2009-01-02 14:33 UTC by Volker Reichelt
Modified: 2009-01-06 13:50 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2009-01-02 16:33:30


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2009-01-02 14:33:36 UTC
The following invalid code snippet triggers an ICE on the trunk:

=================
union U
{
  int i, j;
};

U u({1,2});
=================

bug.cc:6: internal compiler error: in process_init_constructor_union, at cp/typeck2.c:1101
Please submit a full bug report, [etc.]
Comment 1 Paolo Carlini 2009-01-02 15:31:24 UTC
And again...
Comment 2 Jason Merrill 2009-01-03 00:21:19 UTC
Subject: Bug 38698

Author: jason
Date: Sat Jan  3 00:19:55 2009
New Revision: 143024

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=143024
Log:
        PR c++/38698
        * typeck2.c (process_init_constructor_union): Handle excess
        initializers.
        (process_init_constructor_record): Likewise.

        PR c++/38684
        * typeck2.c (digest_init_r): Don't use process_init_constructor
        for non-aggregate classes.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/initlist11.C
    trunk/gcc/testsuite/g++.dg/cpp0x/initlist12.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/typeck2.c
    trunk/gcc/testsuite/ChangeLog

Comment 3 Jakub Jelinek 2009-01-03 00:57:48 UTC
Fixed.
Comment 4 Volker Reichelt 2009-01-04 21:37:00 UTC
Jason, the fix is unfortunately incomplete, because the following testcase
still crashes:

=================
union U {};

U u({ 1 });
=================

bug.cc:3: internal compiler error: in process_init_constructor_union, at cp/typeck2.c:1150
Please submit a full bug report, [etc.]
Comment 5 Jason Merrill 2009-01-06 03:27:50 UTC
Subject: Bug 38698

Author: jason
Date: Tue Jan  6 03:27:39 2009
New Revision: 143111

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=143111
Log:
        PR c++/38698
        * typeck2.c (process_init_constructor_union): Handle union with
        no fields.

        * mangle.c (write_expression): Remove mangling for zero-operand
        casts.

Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/mangle.c
    trunk/gcc/cp/typeck2.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/cpp0x/initlist12.C

Comment 6 Jakub Jelinek 2009-01-06 13:50:44 UTC
Fixed.