public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* more fortran test case(s)
@ 2010-11-20  8:53 Davis, Jimmie
  2010-11-25 18:41 ` Steve Kargl
  0 siblings, 1 reply; 2+ messages in thread
From: Davis, Jimmie @ 2010-11-20  8:53 UTC (permalink / raw)
  To: fortran, gcc-patches

Here are two more test cases provided for the intent of increasing our test suite coverage.  

I think one of them points to a defect, while using the flag -fno-range-check we are creating an integer divide with a result of NaaN to be an error.  real and complex in the same situation store the NaaN and go on.  If someone agrees (perhaps who uses the -fno-range-check compiler option), I would be happy to open up a PR and submit the rather trivial patch.

--bud davis


$ cat ./gcc/gcc/testsuite/gfortran.dg/arith_divide.f
! { dg-do compile }
! This test executes all code paths in gfc_arith_divide
! when executed along with it's companion test
! arith_divide_no_check.f
        implicit none
        integer i,j
        real a,b
        complex c,d
        i = 10/40
        j = 10/0! { dg-error "Division by zero at" }
        a = 10.0/40.0
        b = 10.0/0.0! { dg-error "Division by zero at" }
        c = (1.0,1.0)/(10.0,40.0) !  Not division by zero
        d = (1.0,10.)/(0.0,0.0)! { dg-error "Division by zero at" }
        end
 $ cat ./gcc/gcc/testsuite/gfortran.dg/arith_divide_no_check.f
! { dg-do compile }
! { dg-options "-fno-range-check" }
! This test executes all code paths in gfc_arith_divide
! when executed along with it's companion test
! arith_divide.f

        implicit none
        integer i,j
        real a,b
        complex c,d
        i = 10/40
        j = 10/0! { dg-error "Division by zero at" }
        a = 10.0/40.0
        b = 10.0/0.0
        c = (1.0,1.0)/(10.0,40.0)
        d = (1.0,10.)/(0.0,0.0)
        end
 

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

* Re: more fortran test case(s)
  2010-11-20  8:53 more fortran test case(s) Davis, Jimmie
@ 2010-11-25 18:41 ` Steve Kargl
  0 siblings, 0 replies; 2+ messages in thread
From: Steve Kargl @ 2010-11-25 18:41 UTC (permalink / raw)
  To: Davis, Jimmie; +Cc: fortran, gcc-patches

On Sat, Nov 20, 2010 at 01:44:15AM +0000, Davis, Jimmie wrote:
> Here are two more test cases provided for the intent of increasing
> our test suite coverage.  
> 
> I think one of them points to a defect, while using the flag
> -fno-range-check we are creating an integer divide with a result
> of NaaN to be an error.  real and complex in the same situation
> store the NaaN and go on.  If someone agrees (perhaps who uses
> the -fno-range-check compiler option), I would be happy to open
> up a PR and submit the rather trivial patch.
> 

Bud,

I think that there is ia fundamental difference here.  A NaN for
real and complex can be naturally stored in the floating
representation, so continuing makes some sense.  IEEE 754 also
defined arithmetic operations involving an NaN.  For integer
divide by zero, there isn't a bit pattern available to
encode an integer NaN.  I think that we do not need to do
anything special here with -fno-range-check.  This option
already asks gfortran to violate the standard, so the user
should be prepared to get what gfortran generates.

-- 
Steve

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

end of thread, other threads:[~2010-11-25 17:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-20  8:53 more fortran test case(s) Davis, Jimmie
2010-11-25 18:41 ` Steve Kargl

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).