This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/57628] spurious error: division by zero in if statement


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

Harald Anlauf <anlauf at gmx dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |anlauf at gmx dot de

--- Comment #13 from Harald Anlauf <anlauf at gmx dot de> ---
Hi Ryo!

(In reply to Ryo Furue from comment #10)
> (In reply to Dominique d'Humieres from comment #7)
> > AFAICT the option -fno-range-check is what you are looking for.
> 
> Thanks!  That's exactly it.
> 
> But, I'm curious.  The following code still fails to compile even with
> -fno-range-check :
> 
> program try
>   real, parameter:: a = -1.0
>   if (a > 0) then
>     write(*,*) sqrt(a)
>   end if
> end program try
> 
> $ gfortran -fno-range-check tmp.f90
> tmp.f90:4.20:
> 
>     write(*,*) sqrt(a)
>                     1
> Error: Argument of SQRT at (1) has a negative value
> $
> 
> Is this an inconsistency in the implementation of -no-range-check ?
> 
> I would be nice if there were an option to demote this type of error to a
> warning.

I would also prefer if gfortran behaved as you suggested.
Other compilers appear to generate warnings only, or no comment.
After all, the code path in question never gets executed.

I am afraid that the Fortran standard document does not give
much help here and may allow gfortran's behavior.  Nevertheless
I recommend to ask in comp.lang.fortran where you'll probably
get a better explanation.

> Cheers,
> Ryo


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]