[Bug libfortran/96613] SIGFPE on min1() with -ffpe-trap=invalid switch
kargl at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Aug 14 15:58:44 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96613
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2020-08-14
Ever confirmed|0 |1
CC| |kargl at gcc dot gnu.org
Priority|P3 |P4
--- Comment #1 from kargl at gcc dot gnu.org ---
Compiling with -fdump-tree-original gives
integer(kind=4) ix;
real(kind=4) x;
x = 7.7643945e+9;
{
integer(kind=4) M.0;
M.0 = 5000;
M.0 = MIN_EXPR <(integer(kind=4)) x, M.0>;
ix = M.0;
}
The MIN_EXPR is clealy a bad idea as x > huge(1).
The Fortran standard states, that for example,
MIN1(a,b) = INT(MIN(a,b)). I would have expected
to see something along the lines of
integer(kind=4) ix;
real(kind=4) x;
x = 7.7643945e+9;
{
real(kind=4) M.0;
M.0 = 5000.0;
M.0 = MIN_EXPR <x, M.0>;
ix = (integer(kind=4)) M.0;
}
If this is effecting your code, I suggest changing it to
min1() = int(min()) to work around the issue. This might
get fixed someday when a gfortran contributor has time to
look at it.
More information about the Gcc-bugs
mailing list