This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: Optimisation prevents overflow?
On 7/20/07, Davide Mancusi <arekfu@yahoo.it> wrote:
Janne Blomqvist wrote:
>> 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.
But how do I identify those parts of the code that are relying on extra
precision?
I suppose the proper answer is that you analyze the math behind the
problem that you're trying to solve, and determine which variables can
concievably get such huge/tiny values, and change your program
accordingly. Do note that "changing your program" is not limited to
switching to extended precision, but includes changing the algorithm,
or rescaling the variables, etc. (often a better solution than simply
using more precision).
The quick and dirty answer would be to compile the program with
-ffloat-store or -mfpmath=sse, turn on overflow trapping
(-ffpe-trap=overflow) and see where it goes boom. Fix the relevant
part, and repeat until the program completes successfully.
As you said, in principle all the code is doing it.
I said nothing of the sort.
--
Janne Blomqvist