Bug 23799 - [4.1 regression] ICE: no-op convert from 8 to 4 bytes in initializer
Summary: [4.1 regression] ICE: no-op convert from 8 to 4 bytes in initializer
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.1.0
: P2 normal
Target Milestone: 4.1.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
: 24343 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-09-09 18:00 UTC by Andreas Schwab
Modified: 2005-10-13 00:16 UTC (History)
7 users (show)

See Also:
Host:
Target: 64bit targets
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-10-12 01:24:42


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Schwab 2005-09-09 18:00:46 UTC
Executing on host: /tmp/cvs/gcc-20050909/Build/gcc/testsuite/../g++  
-B/tmp/cvs/gcc-20050909/Build/gcc/testsuite/../ /tmp/cvs/gcc-20050909/gcc/testsuite/g++.dg/init/pr23180-2.C  
-nostdinc++  
-I/tmp/cvs/gcc-20050909/Build/ia64-suse-linux/libstdc++-v3/include/ia64-suse-linux  
-I/tmp/cvs/gcc-20050909/Build/ia64-suse-linux/libstdc++-v3/include  
-I/tmp/cvs/gcc-20050909/libstdc++-v3/libsupc++  
-I/tmp/cvs/gcc-20050909/libstdc++-v3/include/backward  
-I/tmp/cvs/gcc-20050909/libstdc++-v3/testsuite -fmessage-length=0   -ansi  
-pedantic-errors -Wno-long-long  -S  -o pr23180-2.s    (timeout = 300)  
/tmp/cvs/gcc-20050909/gcc/testsuite/g++.dg/init/pr23180-2.C:10: internal  
compiler error: no-op convert from 8 to 4 bytes in initializer
Comment 1 Andrew Pinski 2005-09-09 18:05:24 UTC
Note this is a new testcase for 4.1.  Just to double check, did you try compiling it with 4.0?
Comment 2 Andreas Schwab 2005-09-09 18:51:33 UTC
Sure I did. 
Comment 3 Joseph S. Myers 2005-09-09 20:19:24 UTC
Also appears on ia64-hp-hpux11.23 (-mlp64 only).
Comment 4 Andreas Schwab 2005-09-10 10:19:04 UTC
Also fails on x86-64, according to  
<http://gcc.gnu.org/ml/gcc-testresults/2005-09/msg00458.html>.  All 64-bit 
targets appear to be affected. 
Comment 5 Andrew Pinski 2005-09-14 14:32:23 UTC
Note the testcase is now called struct3.C.

Confirmed.
Comment 6 Andrew Pinski 2005-09-14 17:45:05 UTC
Caused by:
http://gcc.gnu.org/ml/gcc-cvs/2005-09/msg00040.html



Reduced testcase:
struct Track {
  char soundName[15];
};
int foobar = ((long) (& ((Track *) 42)->soundName[0])) - 42;
Comment 7 Steven Bosscher 2005-09-18 10:37:37 UTC
DJ, apparently you caused this one. 
Comment 8 DJ Delorie 2005-09-19 19:57:31 UTC
Subject: Re:  [4.1 regression] ICE: no-op convert from 8 to 4 bytes in initializer


> DJ, apparently you caused this one. 

Yup, and I had reservations about that portion of the patch at the
time, too, which have turned out to be justified (the reservations,
not the patch).

I think the best option at this point is to just take the check out
(leaving in the other part of the patch, which is needed for m32c).

The code will still be buggy if the no-op converts to a larger size,
though, because it doesn't take endianness into account when padding.
I'm rather surprised that the test case works for sizeof(long) >
sizeof(int), I'd expect the bytes to be truncated in amusing ways.
Comment 9 Alan Modra 2005-09-23 05:24:43 UTC
The failures on powerpc64-linux are due to a long (64-bit) to int (32-bit)
conversion.  When such a conversion is the outermost one, as in this case, it
ought to be allowed.  The assembler will (or should) handle big/little endian
issues and give an error on overflow.
Comment 10 DJ Delorie 2005-09-23 17:22:33 UTC
Subject: Re:  [4.1 regression] ICE: no-op convert from 8 to 4 bytes in initializer


I recall that the opposite case is problematic; initializing a large
int from a smaller one, because gcc always zero pads at the end.
Perhaps a lt/gt comparison would be more appropriate?
Comment 11 Richard Biener 2005-10-05 09:11:21 UTC
Any progress on this one?
Comment 12 Richard Biener 2005-10-06 21:26:44 UTC
For the testcase we get at output_constant time for the

C++ frontend: (intD.2) (long intD.5) &42B->soundNameD.2065[-42]                                                 
C frontend: (intD.0) (long intD.2) &42B->soundNameD.1608 - 42

the C++ frontend ICEs, the C frontend not (as we have an outer MINUS_EXPR).

Whatever you wanted to fix with your patch will not work in every case - but
you didn't add a testcase. 
Comment 13 GCC Commits 2005-10-12 08:56:03 UTC
Subject: Bug 23799

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	rguenth@gcc.gnu.org	2005-10-12 08:55:59

Modified files:
	gcc            : ChangeLog varasm.c 

Log message:
	2005-10-12  Richard Guenther  <rguenther@suse.de>
	
	PR c++/23799
	* varasm.c (output_constant): Correct typo from previous
	patch by DJ.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.10142&r2=2.10143
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/varasm.c.diff?cvsroot=gcc&r1=1.531&r2=1.532

Comment 14 Richard Biener 2005-10-12 08:57:22 UTC
Fixed.
Comment 15 Andrew Pinski 2005-10-13 00:16:34 UTC
*** Bug 24343 has been marked as a duplicate of this bug. ***