public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/57496] New: I/O: WRITE(*,*) HUGE(0_16) [REAL(10)+REAL(16)]: Gives SIGFPE with -ffpe-trap=overflow
@ 2013-06-01  8:32 burnus at gcc dot gnu.org
  2013-06-01 18:37 ` [Bug fortran/57496] " burnus at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-06-01  8:32 UTC (permalink / raw)
  To: gcc-bugs

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);\


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-08-24 16:34 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-01  8:32 [Bug fortran/57496] New: I/O: WRITE(*,*) HUGE(0_16) [REAL(10)+REAL(16)]: Gives SIGFPE with -ffpe-trap=overflow burnus at gcc dot gnu.org
2013-06-01 18:37 ` [Bug fortran/57496] " burnus at gcc dot gnu.org
2013-06-03  9:29 ` burnus at gcc dot gnu.org
2013-06-03  9:31 ` [Bug fortran/57496] I/O: WRITE(*,*) HUGE(0._10) gives " burnus at gcc dot gnu.org
2013-06-27  9:46 ` dominiq at lps dot ens.fr
2015-08-16 15:27 ` fxcoudert at gcc dot gnu.org
2015-08-16 15:31 ` [Bug libfortran/57496] " fxcoudert at gcc dot gnu.org
2015-08-24 16:32 ` fxcoudert at gcc dot gnu.org
2015-08-24 16:34 ` fxcoudert at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).