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: wrong code with -fforce-addr


Hi,

I could track it down to essentially the following:

      SUBROUTINE FI635(...)
      INTEGER       KSCALE
      REAL          SCALE
<..some code calculating KSCALE..>
      SCALE = 2.0**KSCALE
      PRINT *,'SCALE ',SCALE,KSCALE

In the working case, I get
 SCALE    1.000000               0
in the non-working case, I have
 SCALE    0.000000               0

If I add further prints, I suddenly get no output at all.
It looks a bit like there is memory corruption, but I ran with efence
and tried valgrind, I didn't find anything.

I'm a bit in a loss. How to debug such a mess?
I also tried to run ftnchek, but it has quite some problems
with this fortran95 code.

Thanks in advance for any hints,
Manfred


-------- Original-Nachricht --------
> Datum: Wed, 29 Aug 2007 10:28:23 +0200
> Von: Manfred Schwarb <manfred99@gmx.ch>
> An: fortran@gcc.gnu.org
> Betreff: wrong code with -fforce-addr

> Hi,
> 
> I have a rather nasty wrong code issue with recent gfortran (of yesterday)
> at higher optimisation levels.
> It's in a large program with a lot of legacy things in it, mixed c and
> fortran (66-95).
> 
> I could track down the error to one subroutine with 300 LOC of fortran95
> (well, fortran66 with
> some few fortran95 statements).
> 
> With "-O2 -fforce-addr", the program produces the correct output,
> with "-O2 -march=pentium4 -fforce-addr" the output is wrong.
> If I omit "-fforce-addr", the output is always correct.
> At optimisation level "-O1", i.e. "-O1 -march=pentium4 -fforce-addr", the
> output is OK.
> 
> The output of -fdump-tree-optimized is the same for the working and
> non-working case.
> As expected, there are differences in the assembler output, however, I do
> not speak assembler.
> 
> As this program has a lot of iterations and a lot of data IO, it seems
> rather unrealistic
> to poke with a debugger or putting in print statements.
> 
> Has anybody an idea how to narrow things?
> What would be the appropriate debug output to see what is going wrong?
> 
> Thanks,
> Manfred
> 

-- 
GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS.
Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail


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