From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7043 invoked by alias); 1 Jun 2013 18:37:03 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 6971 invoked by uid 48); 1 Jun 2013 18:36:53 -0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/57496] I/O: WRITE(*,*) HUGE(0_16) [REAL(10)+REAL(16)]: Gives SIGFPE with -ffpe-trap=overflow Date: Sat, 01 Jun 2013 18:37:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-06/txt/msg00029.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57496 --- Comment #2 from Tobias Burnus --- The submitted patch at http://gcc.gnu.org/ml/fortran/2013-06/msg00005.html actually solves the problem for REAL(16). NOTE: I forgot to change one "isfinite" to "ISFINITE" in OUTPUT_FLOAT_FMT_G. * * * Pre-remark: All the tests below were done on x86-64-gnu-linux with -m64, but I also tried -m32. For REAL(10) it fails at the call: + if (!__finitel (tmp)) I tried the following simple C example, compiled with "gfortran -ffpe-trap=overflow file.c file.f90". Result: no failure (and "T" as output). ------------------------------------ #include _Bool myIsFinite (long double x) { return isfinite (x); } ------------------------------------ use iso_c_binding interface logical(c_bool) function myIsFinite (x) bind(C, name="myIsFinite") import real(c_long_double), value :: x end function myIsFinite end interface print *, myIsFinite(huge(0.0_c_long_double)) end ------------------------------------ The __finitel is handled on x86-64 as library call. I tried to set the break point into __finitel but it seems as if the overflow error occurs before. If I place a printf in libgfortran before the __finitel call, it prints "1.189731e+4932" - before failing in the next line. However, if I compile the file with -ffloat-store, it already fails in the "printf" line; it also fails in that line if compiled with -O0 (and w/o -ffloat-store). For libgfortran's write_float in "case 10:", I now have after manual macro expansion: case 10: { GFC_REAL_10 tmp; tmp = * (GFC_REAL_10 *)source; sign_bit = signbit (tmp); printf ("DEBUG: %Le\n", tmp); /* Added. */ if (!__finitel (tmp)) The assembler code is (without -ffloat-store): call printf .LVL694: .loc 3 1287 0 fldt -192(%rbp) fld %st(0) fstpt (%rsp) .LVL695: fstpt -192(%rbp) call __finitel .LVL696: testl %eax, %eax fldt -192(%rbp) je .L971 While the simple C test case - which doesn't fail - above gives: subq $24, %rsp .cfi_def_cfa_offset 32 fldt 32(%rsp) fstpt (%rsp) call __finitel testl %eax, %eax setne %al addq $24, %rsp .cfi_def_cfa_offset 8 ret