[Bug fortran/118259] -O3 optimisation bug fixed with -fno-inline
mjr19 at cam dot ac.uk
gcc-bugzilla@gcc.gnu.org
Tue Dec 31 19:13:03 GMT 2024
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118259
--- Comment #4 from mjr19 at cam dot ac.uk ---
Add using
seed=iand(seed*int(1103515245,selected_int_kind(18))+12345,z'7fffffff')
also works as expected. Converting the code to C shows the same behaviour as
the Fortran if seed is a static int (overflows on ints are also undefined in
C), whereas using a static unsigned int (for which overflows are defined) gives
the same result at -O3 as at other optimisation levels, and the results I had
expected, but not actually been entitled to.
Thanks for pointing out the consequences of my sloppy Fortran.
More information about the Gcc-bugs
mailing list