optimisation of overflowing integers
Steve Kargl
sgk@troutmask.apl.washington.edu
Tue Mar 18 15:53:00 GMT 2014
On Tue, Mar 18, 2014 at 07:53:04AM +0100, Tobias Burnus wrote:
> N.M. Maclaren wrote:
> > The errors occur at run-time - NAG Fortran is the only currently active
> > Fortran compiler that checks for such things (and you need -C=all).
> > So the answers are "no" and "no".
>
> Try GCC/gfortran 4.9 (with the bug fix patch to PR60557), namely:
>
> $ gfortran -fsanitize=undefined bar.f90
> $ ./a.out
> bar.f90:19: runtime error: signed integer overflow: 809078955 * 65539
> cannot be represented in type 'integer(kind=4)'
> 0.290384561 623596113
>
It appears that if one builds gcc without libsantize, one gets ICEs.
troutmask:sgk[204] gfc4x -o z -fsanitize=undefined ffo1.f90
ffo1.f90: In function 'ribm':
ffo1.f90:14:0: internal compiler error: Segmentation fault
subroutine ribm(rndm,ial)
^
no stack trace because unwind library not available
troutmask:sgk[206] gfc4x -o z -O2 -fsanitize=signed-integer-overflow ffo1.f90
ffo1.f90: In function 'testribm':
ffo1.f90:18:0: internal compiler error: Segmentation fault
ial=ial*65539
^
no stack trace because unwind library not available
--
Steve
More information about the Fortran
mailing list