This is the mail archive of the gcc-help@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]

Re: Exception catching


Hassan Aurag wrote:

>  I would like an example on how to catch all division by zeros in
> Fortran.
> 
>  My idea is the following in pseudo-code:
> 
>  num, denom = catch_div_byzero()
> 
>  return bignumber (and not nan)
> 
>  Is this even possible?

I presume you mean "possible without changing my Fortran source code" ?

>  In other words, I would like to alter division by zero so that it
> returns a huge number. can it be made even in C and then linked as
> library to my fortran code?

No, because the division is done "inline", i.e., no subroutine call is
generated.

However, you might be able to set the floating point control word in
your processor to catch this error instead of silently generating a NaN.

See http://gcc.gnu.org/onlinedocs/g77_19.html#SEC644

[Note that this is really a C library question - notably a glibc
 enabled solution]

Hope this helps,

-- 
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
Join GNU Fortran 95: http://g95.sourceforge.net/ (under construction)


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