This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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: Strange SIGFPE (underflow?) with gfortran [ -mieee ?]


Rob <spamrefuse at yahoo dot com> wrote:
>
> I'm using GCC 4.1.2, from SVN as of about two weeks
> ago. It's on an AlphaServer system with Linux
> installed.
> 
> 
> I have this piece of Fortran code:
> 
> 	      R1=-708.397
> 	      R2=EXP(R1)
> 	      R3=1-R2
> 
> Compiling with gfortran is OK. However, when running
> the executable, I get an SIGFPE Arithmetic exception
> at the line with the R3 assignment. Using gdb, I get
> these values:
> 
>   R1 = -708.39697265625
>   R2 = 2.2238412332569656e-308
>   R3 = 0
> 
> The value of R3 should be 1, as R2 is close to zero.
> I suppose the FPE is an underflow exception, but
> why is the underflow not squashed to zero?
> 
> 
> However, when I change the first line to
> 	      R1=708.396
> 
> (change last digit from 7 to 6) then the SIGFPE
> disappears when running the executable. In that
> case I have (using gdb):
> 
>   R1 = -708.39599609375
>   R2 = 2.2260140139667223e-308
>   R3 = 1
> 
> 
> Is this a problem with the gfortran compiler?
> 
> Is there a flag I can pass during compilation
> and/or linking, to avoid such problems?

I kind of solved this problem with the "-mieee"
flag, a specific flag for the Alpha system.
I have two concerns here:

  1) Do I still get the correct arithmetic with
     this flag? I mean, I don't want to suppress
     the SIGFPE and continue the program with
     random values in my variables.

  2) The manpage says that the -mieee flag will
     produce less efficient code. Is there another
     flag that also solves my problem, but without
     compromising on the code's efficiency?

Thank you!
Rob.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


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