gcc build with "-fsanitize=undefined" hits the following issue when compiling testsuite/gfortran.dg/integer_exponentiation_5.F90: markus@x4 gfortran % /var/tmp/gcc_build_dir_/gcc/testsuite/gfortran/../../gfortran -B/var/tmp/gcc_build_dir_/gcc/testsuite/gfortran/../../ -B/var/tmp/gcc_build_dir_/x86_64-unknown-linux-gnu/./libgfortran/ /var/tmp/gcc/gcc/testsuite/gfortran.dg/integer_exponentiation_5.F90 -fno-diagnostics-show-caret -fdiagnostics-color=never -O0 -fno-range-check -B/var/tmp/gcc_build_dir_/x86_64-unknown-linux-gnu/./libgfortran/.libs -L/var/tmp/gcc_build_dir_/x86_64-unknown-linux-gnu/./libgfortran/.libs -L/var/tmp/gcc_build_dir_/x86_64-unknown-linux-gnu/./libgfortran/.libs -B/var/tmp/gcc_build_dir_/x86_64-unknown-linux-gnu/./libquadmath/.libs -L/var/tmp/gcc_build_dir_/x86_64-unknown-linux-gnu/./libquadmath/.libs -L/var/tmp/gcc_build_dir_/x86_64-unknown-linux-gnu/./libquadmath/.libs -lm -o ./integer_exponentiation_5.exe ../../gcc/gcc/hwint.h:250:19: runtime error: shift exponent 64 is too large for 64-bit type 'long int' ../../gcc/gcc/hwint.h:250:29: runtime error: shift exponent 64 is too large for 64-bit type 'long int'
This failure is caused by the caller trying to sign extend something with a precision of zero. This bug should be fixed upstream of this call.
Thanks. Backtrace shows that it is a Fortran issue: Breakpoint 1, 0x00007ffff6e33160 in __ubsan::Diag::~Diag() () from /usr/lib/gcc/x86_64-pc-linux-gnu/5.0.0/libubsan.so.0 (gdb) bt #0 0x00007ffff6e33160 in __ubsan::Diag::~Diag() () from /usr/lib/gcc/x86_64-pc-linux-gnu/5.0.0/libubsan.so.0 #1 0x00007ffff6e35e1a in handleShiftOutOfBoundsImpl(__ubsan::ShiftOutOfBoundsData*, unsigned long, unsigned long, __ubsan::ReportOptions) () from /usr/lib/gcc/x86_64-pc-linux-gnu/5.0.0/libubsan.so.0 #2 0x00007ffff6e36613 in __ubsan_handle_shift_out_of_bounds () from /usr/lib/gcc/x86_64-pc-linux-gnu/5.0.0/libubsan.so.0 #3 0x00000000019d5e10 in sext_hwi (prec=<optimized out>, src=<optimized out>) at ../../gcc/gcc/hwint.h:250 #4 set_len (is_sign_extended=<optimized out>, l=<optimized out>, this=<optimized out>) at ../../gcc/gcc/wide-int.h:1075 #5 wi::from_mpz (type=0x11, x=0x53b5e20, wrap=64, wrap@entry=true) at ../../gcc/gcc/wide-int.cc:265 #6 0x00000000007633a5 in gfc_conv_mpz_to_tree (i=0x53b5e20, kind=8) at ../../gcc/gcc/fortran/trans-const.c:206 #7 0x0000000000764c38 in gfc_conv_constant (se=0x7fffffffd760, expr=0x53b5da0) at ../../gcc/gcc/fortran/trans-const.c:403 #8 0x00000000007aec0b in gfc_conv_expr (se=se@entry=0x7fffffffd760, expr=expr@entry=0x53b5da0) at ../../gcc/gcc/fortran/trans-expr.c:6520 #9 0x00000000007ba908 in gfc_conv_expr_reference (se=0x7fffffffd760, expr=0x53b5da0) at ../../gcc/gcc/fortran/trans-expr.c:6651 #10 0x00000000007a0ccf in gfc_conv_procedure_call (se=0x7fffffffd170, se@entry=0x7fffffffd8b0, sym=0x4396944, args=0x7fffffffd1f0, args@entry=0x53aa0d0, expr=0x40, expr@entry=0x0, append_args=0x4396940, append_args@entry=0x0) at ../../gcc/gcc/fortran/trans-expr.c:4429 #11 0x0000000000831728 in gfc_trans_call (code=code@entry=0x53b5e70, dependency_check=<optimized out>, mask=mask@entry=0x0, count1=count1@entry=0x0, invert=invert@entry=false) at ../../gcc/gcc/fortran/trans-stmt.c:408 #12 0x0000000000726aca in trans_code (code=0x53b5e70, cond=cond@entry=0x0) at ../../gcc/gcc/fortran/trans.c:1717 #13 0x000000000072a277 in gfc_trans_code (code=<optimized out>) at ../../gcc/gcc/fortran/trans.c:1928 #14 0x0000000000789f34 in gfc_generate_function_code (ns=<optimized out>) at ../../gcc/gcc/fortran/trans-decl.c:5789 #15 0x000000000072a2a5 in gfc_generate_code (ns=<optimized out>) at ../../gcc/gcc/fortran/trans.c:1945 #16 0x000000000068148b in translate_all_program_units (gfc_global_ns_list=0x53a48b0) at ../../gcc/gcc/fortran/parse.c:4947 #17 gfc_parse_file () at ../../gcc/gcc/fortran/parse.c:5144 #18 0x0000000000715db8 in gfc_be_parse_file () at ../../gcc/gcc/fortran/f95-lang.c:212 #19 0x000000000129d388 in compile_file () at ../../gcc/gcc/toplev.c:551 #20 0x00000000012a0aab in do_compile () at ../../gcc/gcc/toplev.c:1946 #21 toplev_main (argc=20, argv=0x7fffffffe038) at ../../gcc/gcc/toplev.c:2022 #22 0x00007ffff6ae1fd0 in __libc_start_main () from /lib/libc.so.6 #23 0x000000000058d3a1 in _start () (gdb)
Caused by wi::from_mpz mishandling the wrap operation. Related, a testcase like: program test write (*), (2_8 ** 64009999_2) / 2 end program test (compiled with -fno-range-check) writes way beyond the buffer.
Author: rsandifo Date: Mon Feb 23 23:02:50 2015 New Revision: 220921 URL: https://gcc.gnu.org/viewcvs?rev=220921&root=gcc&view=rev Log: gcc/ PR fortran/63427 * wide-int.cc (wi::from_mpz): Cope with unwrapped values that are too big for a wide_int. Implement missing wrapping operation. gcc/testsuite/ PR fortran/63427 * gfortran.dg/integer_exponentiation_6.F90: New test. Added: trunk/gcc/testsuite/gfortran.dg/integer_exponentiation_6.F90 Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/wide-int.cc
closing as fixed