Bug 64327 - ../../gcc/gcc/rtlanal.c:4881:48: runtime error: shift exponent 4294967295 is too large for 64-bit type 'long unsigned int'
Summary: ../../gcc/gcc/rtlanal.c:4881:48: runtime error: shift exponent 4294967295 is ...
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 5.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 66853 (view as bug list)
Depends on:
Blocks: ubsan
  Show dependency treegraph
 
Reported: 2014-12-16 08:49 UTC by Markus Trippelsdorf
Modified: 2018-04-03 12:01 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 7.3.0, 8.0
Known to fail: 6.4.0
Last reconfirmed: 2014-12-17 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Trippelsdorf 2014-12-16 08:49:48 UTC
Running bootstrap-ubsan on x86_64 shows many instances of:

../../gcc/gcc/rtlanal.c:4881:48: runtime error: shift exponent 4294967295 is too large for 64-bit type 'long unsigned int'
Comment 1 Marek Polacek 2014-12-17 13:11:23 UTC
I see that too.
Comment 2 Vittorio Zecca 2015-07-13 07:45:42 UTC
Please see bug 66853, it appears to duplicate this one.
With a small reproducer included.
Comment 3 Markus Trippelsdorf 2015-07-13 07:50:49 UTC
*** Bug 66853 has been marked as a duplicate of this bug. ***
Comment 4 Vittorio Zecca 2015-07-14 07:36:00 UTC
For your convenience I repeat here the reproducer:
/* from gcc file fixopts.c */
/* must be compiled with -O2 */
/*gcc-5.1.0/gcc/rtlanal.c:4911:48: runtime error: shift exponent
4294967295 is too large for 64-bit type 'long unsigned int'*/
/*on source line "return nonzero & ((unsigned HOST_WIDE_INT) 1 <<
(bitwidth - 1))"*/
/* because unsigned int bitwidth is zero and bitwitdth-1 is 4294967295
on my x86-64 */
/* I did double check with:
 *   bitwidth = GET_MODE_PRECISION (mode);
 *   gcc_assert(bitwidth);
*/
/* the bug appears compiling fixopts.c crc32.c md5.c and many Fedora
21 kernel files*/
/* 66853 duplicato di 64327 */
int strcmp(const char *s1, const char *s2);
int  fixinc_mode; /* must be outside main for bug to appear */
int main (void)
{
 const char *pz;
 if (strcmp (pz, "true") ) fixinc_mode = 0;
}
Comment 5 Vittorio Zecca 2015-07-20 05:20:18 UTC
In 5.2.0 too.
Comment 6 Vittorio Zecca 2015-08-23 05:31:09 UTC
I "fixed" this one by substituting rtlanal.c:4907

if (bitwidth > HOST_BITS_PER_WIDE_INT )

with

if (bitwidth > HOST_BITS_PER_WIDE_INT || !bitwidth)
Comment 7 Vittorio Zecca 2016-04-30 05:19:15 UTC
On 6.1.0 I applied the same patch I suggested on comment 6,
this time at line 5187,
and the runtime error disappeared.
Comment 8 Martin Liška 2018-03-01 11:45:38 UTC
Can't reproduce on trunk any longer. Vittorie can you please re-test?
Comment 9 Vittorio Zecca 2018-04-03 05:56:32 UTC
Sorry for the delay in answering but I was traveling.

I cannot reproduce on version 7, while it reproduces on 6.4.0.
Comment 10 Martin Liška 2018-04-03 12:01:24 UTC
Ok, so let's close it when GCC-6 will be closed.