This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/78588] rtlanal.c:5210:38: runtime error: shift exponent 4294967295 is too large for 64-bit type 'long unsigned int'
- From: "trippels at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 30 Nov 2016 07:31:26 +0000
- Subject: [Bug rtl-optimization/78588] rtlanal.c:5210:38: runtime error: shift exponent 4294967295 is too large for 64-bit type 'long unsigned int'
- Auto-submitted: auto-generated
- References: <bug-78588-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78588
--- Comment #1 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
Author: trippels
Date: Wed Nov 30 07:30:55 2016
New Revision: 242997
URL: https://gcc.gnu.org/viewcvs?rev=242997&root=gcc&view=rev
Log:
Fix PR78588 - rtlanal.c:5210:38: runtime error: shift exponent 4294967295 is
too large for 64-bit type
Building gcc with -fsanitize=undefined shows:
rtlanal.c:5210:38: runtime error: shift exponent 4294967295 is too large for
64-bit type 'long unsigned int'
This happens because if_then_else_cond() in combine.c calls
num_sign_bit_copies() in rtlanal.c with mode==BLKmode.
5205 bitwidth = GET_MODE_PRECISION (mode);
5206 if (bitwidth > HOST_BITS_PER_WIDE_INT)
5207 return 1;
5208
5209 nonzero = nonzero_bits (x, mode);
5210 return nonzero & (HOST_WIDE_INT_1U << (bitwidth - 1))
5211 ? 1 : bitwidth - floor_log2 (nonzero) - 1;
This causes (bitwidth - 1) to wrap around.
PR rtl-optimization/78588
* combine.c (if_then_else_cond): Also guard against BLKmode.
* rtlanal.c (num_sign_bit_copies1): Add assert.
Modified:
trunk/gcc/ChangeLog
trunk/gcc/combine.c
trunk/gcc/rtlanal.c