[Bug fortran/57628] spurious error: division by zero in if statement
furue at hawaii dot edu
gcc-bugzilla@gcc.gnu.org
Mon Jun 17 21:42:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57628
--- Comment #15 from Ryo Furue <furue at hawaii dot edu> ---
(In reply to Harald Anlauf from comment #13)
Hi Harald,
Thanks for your message.
> 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.
I'm pretty sure that the Fortran standard allows gfortran's behavior. I'm not
arguing that it's a violation of the standard. I'm just asking for an option
to change the behavior (which would also within the standard).
The question is what is the best way to deal with illegal bits of code. There,
there are a number of choices all within the standard. For example, with this
program try
real:: a(10) = 1.0/0.0
write(10) a
end program try
the compiler is allowed to do anything and there is no single answer as to
what's best. In some circumstances, to stop compiling with an error message is
the best way (gfortran's default behavior); in some circumstances, to replace
the constant expression with the IEEE +Infinity value and let the code pass
(-fno-range-check) is a better choice. I certainly would write such a code as
the above to get a binary array of Infinities. (It's a quick-n-dirty way but it
works in practice.)
In other circumstances, the compiler can send en email message to the writer of
such a code, pointing out the stupidity of it :-)
Cheers,
Ryo
More information about the Gcc-bugs
mailing list