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


> On Wed, Aug 29, 2007 at 07:45:31PM +0200, Manfred Schwarb wrote:
> > 
> >       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.
> > 
> 
> Can you post the entire subroutine that shows the problem?
> You may have already mentioned the version, but could you
> also include 'gfortran -v' output?

I encountered it first with a 2 weeks' old version, but I have
reproduced it with FX's build of 2007-08-28:
# gfortran -v
Using built-in specs.
Target: i386-pc-linux-gnu
Configured with: /home/fx/gfortran_nightbuild/trunk/configure --prefix=/home/fx/gfortran_nightbuild/irun-20070828 --enable-languages=c,fortran --build=i386-pc-linux-gnu --enable-checking=release --with-gmp=/home/fx/gfortran_nightbuild/software
Thread model: posix
gcc version 4.3.0 20070828 (experimental) [trunk revision 127846] (GCC)

Sorry, I can't provide a standalone, reduced test case,
I could not reduce the code any further, but I was lucky and 
found a trigger in the affected subroutine:
Adding an additional print statement got the thing working again.
==> If I have a print statement in line 145 (as in the attached source),
then the resulting binary works and gives the correct results.
==> If I comment the line 145 out, the resulting binary gives wrong
output, the numerical output is complete nonsense.

Both versions are compiled with
gfortran -O3 -march=pentium4 -mfpmath=sse -msse3 -fforce-addr -c w3fi63-7.f

Then again, if I compile the broken variant (commented print) with
gfortran -O3 -march=pentium4 -mfpmath=sse -msse3 -c w3fi63-7.f
the resulting binary works. Here, dump-tree-original is identical, as
well as dump-tree-optimized. The assembler code is different.


Thanks,
Manfred

> -- 
> Steve

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

Attachment: w3fi63-7.f
Description: Binary data


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