http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57496

            Bug ID: 57496
           Summary: I/O: WRITE(*,*) HUGE(0_16) [REAL(10)+REAL(16)]: Gives
                    SIGFPE with -ffpe-trap=overflow
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
                CC: jb at gcc dot gnu.org, jvdelisle at gcc dot gnu.org

Reported at http://gcc.gnu.org/ml/fortran/2013-05/msg00136.html /
http://gcc.gnu.org/ml/fortran/2013-05/msg00138.html


The following program gives a floating-point exception when compiled with
-ffpe-trap=overflow:

print *, huge(0.0_10)
print *, huge(0.0_16)
end

The segfault occurs for:
      WRITE_FLOAT(10,L)
and
      WRITE_FLOAT(16,Q)
in libgfortran/io/write_float.def



I have not debugged the code. However, I realized that the following has to be
done - in addition - as one otherwise calls the wrong functions for __float128.


--- a/libgfortran/io/write_float.def
+++ b/libgfortran/io/write_float.def
@@ -963,0 +964,28 @@ __qmath_(quadmath_snprintf) (buffer, size, "%+-#.*Qf", \
+#if defined(GFC_REAL_16_IS_FLOAT128)
+#define ISFINITE2(prec,val) finiteq(val)
+#endif
+#define ISFINITE2(prec,val) isfinite(val)
+#define ISFINITE2L(prec,val) isfinite(val)
+
+#define ISFINITE(suff,val) TOKENPASTE(ISFINITE2,suff)(val)
+
+
+#if defined(GFC_REAL_16_IS_FLOAT128)
+#define SIGNBIT2(prec,val) signbitq(val)
+#endif
+#define SIGNBIT2(prec,val) signbit(val)
+#define SIGNBIT2L(prec,val) signbit(val)
+
+#define SIGNBIT(suff,val) TOKENPASTE(SIGNBIT2,suff)(val)
+
+
+#if defined(GFC_REAL_16_IS_FLOAT128)
+#define ISNAN2(prec,val) isnanq(val)
+#endif
+#define ISNAN2(prec,val) isnan(val)
+#define ISNAN2L(prec,val) isnan(val)
+
+#define ISNAN(suff,val) TOKENPASTE(ISNAN2,suff)(val)
+
+
+
@@ -1197,2 +1225,2 @@ determine_en_precision (st_parameter_dt *dtp, const fnode
-       sign_bit = signbit (tmp);\
-       if (!isfinite (tmp))\
+       sign_bit = SIGNBIT (x,tmp);\
+       if (!ISFINITE (x,tmp))\
@@ -1200 +1228 @@ determine_en_precision (st_parameter_dt *dtp, const fnode *f,
-           write_infnan (dtp, f, isnan (tmp), sign_bit);\
+           write_infnan (dtp, f, ISNAN (x,tmp), sign_bit);\

Reply via email to