[Bug middle-end/115967] New: ubsan: shift exponent 64 is too large for 64-bit type HOST_WIDE_INT in ext-dce.cc on line 600 since r15-1901-g98914f9eba5f19
jamborm at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Jul 17 11:48:22 GMT 2024
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115967
Bug ID: 115967
Summary: ubsan: shift exponent 64 is too large for 64-bit type
HOST_WIDE_INT in ext-dce.cc on line 600 since
r15-1901-g98914f9eba5f19
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: jamborm at gcc dot gnu.org
CC: law at gcc dot gnu.org
Blocks: 63426
Target Milestone: ---
Host: x86_64-linux
Target: x86_64-linux
Undefined behavior sanitizer reports a failure when running Fortran
testcase gfortran.dg/ieee/large_1.f90 at -O2 and higher:
/home/mjambor/gcc/mine/src/gcc/ext-dce.cc:600:15: runtime error: shift
exponent 64 is too large for 64-bit type 'long unsigned int'
/home/mjambor/gcc/mine/src/gcc/ext-dce.cc:404:23: runtime error: left shift
of negative value -1
FAIL: gfortran.dg/ieee/large_1.f90 -O2 (test for excess errors)
The failure is present since the introduction of the source file
ext-dce.cc with commit r15-1901-g98914f9eba5f19 (Jeff Law:
[to-be-committed][RISC-V][V3] DCE analysis for extension elimination)
One way to reproduce the issue is to bootstrap GCC with Fortran
enabled and with --with-build-config=bootstrap-ubsan and then run the
test case as usual.
It is however much easier to (on an x86_64-linux at least) simply
apply the following patch and then run
make -k check-gfortran RUNTESTFLAGS="ieee.exp=large_1.f90"
--- a/gcc/ext-dce.cc
+++ b/gcc/ext-dce.cc
@@ -597,6 +597,7 @@ ext_dce_process_uses (rtx_insn *insn, rtx obj, bitmap
live_tmp)
bit = subreg_lsb (y).to_constant ();
if (dst_mask)
{
+ gcc_assert (bit < 64);
dst_mask <<= bit;
if (!dst_mask)
dst_mask = -0x100000000ULL;
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63426
[Bug 63426] [meta-bug] Issues found with -fsanitize=undefined
More information about the Gcc-bugs
mailing list