[Bug fortran/57749] -ffpe-trap=zero or invalid produces SIGFPE on complex zero ** 1e0
zeccav at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Jul 2 07:22:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57749
--- Comment #16 from Vittorio Zecca <zeccav at gmail dot com> ---
You are being a little too hard on me, but so be it.
I believe there is only one special case, base==0,
and that there are only two ifs to put in cpow to avoid the floating exception
and give the expected result(I am simplifying here, also because I do
not use C):
if(base==0)
{
if(exponent>0) return 0; else raise hell;
}
The actual code where the original issue occurred had the exponentiation
in the deep of nested loops, it would have been rather time consuming
to test base==0
at the Fortran level
And I still do not understand why if the exponent is integer no
exception is raised and
the expected result zero is delivered.
As in the following fragment (with option -ffpe-trap=zero,invalid):
complex x
x=cmplx(0e0,0e0)
i=2
r=2e0
print *,x**i ! no exception raised delivers zero
print *,x**r ! exception raised
end
The Intel ifort and NAG nagfor compilers raise no exceptions and
deliver the expected result.
With my best wishes of good work to everybody.
More information about the Gcc-bugs
mailing list