Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* 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

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