Bug 3620 - GCC3.0 optimization on anonymous union causes ICE
Summary: GCC3.0 optimization on anonymous union causes ICE
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.0
: P3 normal
Target Milestone: ---
Assignee: Mark Mitchell
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2001-07-09 06:26 UTC by mak
Modified: 2003-07-25 17:33 UTC (History)
3 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mak 2001-07-09 06:26:00 UTC
ICE occurs with the following code and -O option:
--------------------------------------test.cpp
void something(char *);

int main()
{
        union {
                char d[sizeof(int)];
                int ll;
        };
        something(d);
        return ll;
}
-----------------------------------------------
mak@tetley% gcc -v
Reading specs from /home/users/mak/local/Linux-i686/lib/gcc-lib/i686-pc-linux-gnu/3.0/specs
Configured with: ../configure --prefix=/home/users/mak/local/Linux-i686
Thread model: single
gcc version 3.0
mak@tetley% g++ -O hoge.cpp
hoge.cpp: In function `int main()':
hoge.cpp:12: Internal compiler error in elimination_effects, at reload1.c:2687
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.

Release:
3.0

Environment:
System: Linux tetley.is.s.u-tokyo.ac.jp 2.2.16-22enterprise #1 SMP Tue Aug 22 16:29:32 EDT 2000 i686 unknown
Architecture: i686
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../configure --prefix=/home/users/mak/local/Linux-i686

How-To-Repeat:
       See description.
Comment 1 mak 2001-07-09 06:26:00 UTC
Fix:
       Work around is to give a name to the union.

int main()
{
        union {
                char d[sizeof(int)];
                int ll;
        } some_name;
        something(some_name.d);
        return some_name.ll;
}

-- 
MAKINO Takaki <mak@is.s.u-tokyo.ac.jp>
Comment 2 Nathan Sidwell 2001-07-09 13:46:13 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: confirmed as a 2.95 regression
Comment 3 niemayer.viag 2001-07-10 17:18:40 UTC
From: Peter Niemayer <niemayer.viag@isg.de>
To: gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org,
	nobody@gcc.gnu.org, mak@is.s.u-tokyo.ac.jp
Cc:  
Subject: Re: c++/3620
Date: Tue, 10 Jul 2001 17:18:40 +0200

 >  Synopsis:          GCC3.0 optimization on anonymous union causes ICE
 
 >  Description:       ICE occurs with the following code and -O option:
 >                     --------------------------------------test.cpp
 >                     void something(char *);
 > 
 >                     int main()
 >                     {
 >                     union {
 >                     char d[sizeof(int)];
 >                     int ll;
 >                     };
 >                     something(d);
 >                     return ll;
 >                     }
 >                     -----------------------------------------------
 
 Interestingly, this bug is very similar to one that I reported a long
 time ago (PR 228) and that was also fixed a long time ago:
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=228&database=gcc
 
 This old bug is still fixed with gcc-3.0 - so maybe the fix of the old
 bug introduced the new one?
 
 Regards,
 
 Peter Niemayer
Comment 4 Mark Mitchell 2001-07-19 19:44:28 UTC
Responsible-Changed-From-To: unassigned->mmitchel
Responsible-Changed-Why: Working on a fix.
Comment 5 Mark Mitchell 2001-08-07 14:00:23 UTC
State-Changed-From-To: analyzed->closed
State-Changed-Why: Already fixed.