[PATCH] PR fortran/96613 - SIGFPE on min1() with -ffpe-trap=invalid switch

Harald Anlauf anlauf@gmx.de
Mon Aug 17 20:36:55 GMT 2020


While looking at the reported issue, it appeared that the Fortran frontend
mishandled the conversion of functions of the MIN/MAX variety to inline code.
At the same time, the simplification of expressions using a common and GNU
extension (but non-standard) could result in inconsistent results.  The patch
below addresses that.

Regtested on x86_64-pc-linux-gnu.

OK for master?

Thanks,
Harald


PR fortran/96613 - Fix type/kind of temporaries evaluating MIN/MAX

When evaluating functions of the MIN/MAX variety inline, use a temporary
of appropriate type and kind, and convert to the result type at the end.
In the case of allowing for the GNU extensions to MIN/MAX, derive the
result kind consistently during simplificaton.

gcc/fortran/ChangeLog:

	* simplify.c (min_max_choose): The simplification result shall
	have the highest kind value of the arguments.
	* trans-intrinsic.c (gfc_conv_intrinsic_minmax): Choose type and
	kind of intermediate by looking at all arguments, not the result.

gcc/testsuite/ChangeLog:

	* gfortran.dg/min_max_kind.f90: New test.
	* gfortran.dg/pr96613.f90: New test.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr96613.patch
Type: text/x-patch
Size: 4627 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20200817/4fd1416c/attachment-0001.bin>


More information about the Gcc-patches mailing list