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;
Already recorded as PR 115876 . *** This bug has been marked as a duplicate of bug 115876 ***