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: Optimisation prevents overflow?


On 7/20/07, Davide Mancusi <arekfu@yahoo.it> wrote:
Brooks Moses wrote:
> So, yeah, -ffloat-store or -mfpmath=sse is the right answer.

This brings me to a "philosophical" question, then. Say that program
"foo" gives different results depending on the use of -ffloat-store; I
am not talking about round-off here, I mean real differences. Would you
say that "foo" is not portable?

Yes. If you need more precision or range than what real(8) provides you have to use a type with more precision and/or range rather than relying on the compiler to keep the variable in the 80-bit x87 register stack.

Gfortran supports real(10) on x86 and x86-64, which ensures no loss of
precision, range, or roundoff when storing an x87 fp register to
memory.

In other words, relying on overflow (or
underflow) is obviously not portable, but is overflow the _only_ way to
trigger inconsistent behaviours?

Depending on your definition of inconsistent, almost anything that has to do with floating point might lead to inconsistent behaviour between different hardware, compilers, optimization levels and whatnot. ;-)

See the Goldberg article for more information (google for "Goldberg
floating point").

--
Janne Blomqvist


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