* Fortran is strange on DEC Alpha
@ 1995-01-04 8:34 Joerg Stadler
1995-01-04 16:17 ` Steve Lionel
1995-01-05 2:09 ` John Hascall
0 siblings, 2 replies; 4+ messages in thread
From: Joerg Stadler @ 1995-01-04 8:34 UTC (permalink / raw)
Hello everybody,
we stumbeled over this piece of fortran-code yesterday
program another_bug
i=256
print *, (2*i-1)*4194304
end
When compiled with f77 and default options, this works as expected.
BUT, when I use f77 -check overflow it aborts:
>f77 -check overflow t.f
>a.out
forrtl: error: floating point exception
IOT trap (core dumped)
>
According to the manpage -check overflow generates traps on interger
overflows.
Now, this behavior is STRANGE (at least to me) because
first, the above program only does INTEGER calculations but the system
reports a FLOATING point exception.
second, the above expression DOES NOT RESULT in an overflow. The expession
(2*256 - 1)*4194304 (a)
can be written as
(2**8 - 1) * 2**22 (b)
which is LESS than 2**31. Maybe the compiler evaluates it as
2**8 * 2**22 - 2**22 (c)
That would explain trap (but not the floating exception errormessage).
My question ist: Is the compiler free to do such transformations as
from (a) to (c), which are mathematically (but not numerically)
equivalent? If so, is there a way to stop it? Or at least a way of
knowing which transformations where applied (i.e. a way to find out
whats going on :-) ).
BTW, this discussion is based on the assumption of 32bit integers, we
are running on OSF1 V3.0 347 alpha and DEC Fortran V3.5-576.
Any ideas?
Thanks
joerg
--
J"org Stadler joerg@itap.physik.uni-stuttgart.de
Inst. f. Theoretische und Angewandte Physik Phone: 0711 / 685 - 5268
Universit"at Stuttgart Pfaffenwaldring 57 Room 6.346
70550 Stuttgart
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Fortran is strange on DEC Alpha
1995-01-04 8:34 Fortran is strange on DEC Alpha Joerg Stadler
@ 1995-01-04 16:17 ` Steve Lionel
1995-01-05 2:09 ` John Hascall
1 sibling, 0 replies; 4+ messages in thread
From: Steve Lionel @ 1995-01-04 16:17 UTC (permalink / raw)
In article <JOERG.95Jan4093450@wilma.physik.uni-stuttgart.de>,
joerg@wilma.physik.uni-stuttgart.de (Joerg Stadler) writes:
|>we stumbeled over this piece of fortran-code yesterday
|>
|> program another_bug
|>
|> i=256
|> print *, (2*i-1)*4194304
|>
|> end
|>
|>When compiled with f77 and default options, this works as expected.
|>BUT, when I use f77 -check overflow it aborts:
We'll look into this. In the meantime, please report the problem through
your Digital software support contact.
--
Steve Lionel Mail: lionel@quark.enet.dec.com
DEC Fortran Development WWW: http://www.digital.com/info/slionel.html
Digital Equipment Corporation CompuServe: 75263,3001
110 Spit Brook Road, ZKO2-3/N30
Nashua, NH 03062-2698 "Free advice is worth every cent"
For a summary of Digital's Internet services, send mail to info@digital.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Fortran is strange on DEC Alpha
1995-01-04 8:34 Fortran is strange on DEC Alpha Joerg Stadler
1995-01-04 16:17 ` Steve Lionel
@ 1995-01-05 2:09 ` John Hascall
1995-01-05 9:15 ` Joerg Stadler
1 sibling, 1 reply; 4+ messages in thread
From: John Hascall @ 1995-01-05 2:09 UTC (permalink / raw)
}The expession
} (2*256 - 1)*4194304 (a)
}can be written as
} (2**8 - 1) * 2**22 (b)
Umm, isn't that ((2**9) - 1) * (2**22)
John
--
John Hascall ``An ill-chosen word is the fool's messenger.''
Systems Software Engineer, ISU Comp Center + Ames, IA 50011 + 515/294-9551
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Fortran is strange on DEC Alpha
1995-01-05 2:09 ` John Hascall
@ 1995-01-05 9:15 ` Joerg Stadler
0 siblings, 0 replies; 4+ messages in thread
From: Joerg Stadler @ 1995-01-05 9:15 UTC (permalink / raw)
>>>>> "John" == John Hascall <john@iastate.edu> writes:
}The expession
} (2*256 - 1)*4194304 (a)
}can be written as
} (2**8 - 1) * 2**22 (b)
John> Umm, isn't that ((2**9) - 1) * (2**22)
Oops, of course you're right. Sorry for that.
joerg
--
J"org Stadler joerg@itap.physik.uni-stuttgart.de
Inst. f. Theoretische und Angewandte Physik Phone: 0711 / 685 - 5268
Universit"at Stuttgart Pfaffenwaldring 57 Room 6.346
70550 Stuttgart
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1995-01-05 9:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1995-01-04 8:34 Fortran is strange on DEC Alpha Joerg Stadler
1995-01-04 16:17 ` Steve Lionel
1995-01-05 2:09 ` John Hascall
1995-01-05 9:15 ` Joerg Stadler
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox