[patch] Backport fix for PR libfortran/26253

John David Anglin dave@hiauly1.hia.nrc.ca
Mon Jan 21 10:24:00 GMT 2008


I would like to backport the enclosed small change to 4.2/4.1 to fix
libfortran/26253 and libfortran/34699 on these branches.  It avoids
the rounding errors associated with using pow.  Appears safe to me.

Tested on 4.2 with hppa1.1-hp-hpux10.20.  It's also been on the
trunk for just under three months with no regressions.

Ok?

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

2008-01-19  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>

	PR libfortran/34699
	Backport:
	2007-09-21  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>

	PR libfortran/26253
	* intrinsics/c99_functions.c (scalbn): Use ldexp if appopriate.

Index: intrinsics/c99_functions.c
===================================================================
--- intrinsics/c99_functions.c	(revision 131440)
+++ intrinsics/c99_functions.c	(working copy)
@@ -249,7 +249,11 @@
 double
 scalbn(double x, int y)
 {
+#if (FLT_RADIX == 2) && defined(HAVE_LDEXP)
+  return ldexp (x, y);
+#else
   return x * pow(FLT_RADIX, y);
+#endif
 }
 #endif
 



More information about the Fortran mailing list