[Bug fortran/18998] Gfortran produces wrong output (c/f to g77)

2004-12-20 Thread tobi at gcc dot gnu dot org

--- Additional Comments From tobi at gcc dot gnu dot org  2004-12-20 22:40 
---
The problem is an out-of-bounds array access to sa, note its dimensions and the
values the loop index takes on.

-- 
   What|Removed |Added

 CC||tobi at gcc dot gnu dot org
 Status|NEW |RESOLVED
 Resolution||INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18998


[Bug fortran/18998] Gfortran produces wrong output (c/f to g77)

2004-12-20 Thread tobi at gcc dot gnu dot org

--- Additional Comments From tobi at gcc dot gnu dot org  2004-12-20 22:40 
---
Forgot to say: this bug is caught by -fbounds-check.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18998


[Bug fortran/18998] Gfortran produces wrong output (c/f to g77)

2004-12-20 Thread Tobias dot Schlueter at physik dot uni-muenchen dot de

--- Additional Comments From Tobias dot Schlueter at physik dot 
uni-muenchen dot de  2004-12-21 00:04 ---
Subject: Re:  Gfortran produces wrong output (c/f to g77)

Deji Akingunola wrote:
--- Additional Comments From tobi at gcc dot gnu dot org  2004-12-20 
22:40 ---
The problem is an out-of-bounds array access to sa, note its dimensions and 
the
values the loop index takes on.

 
 I'm sorry I don't get the above, what do you mean by 'out-of-bound array
 access to sa' (what's sa). I wonder why it's tagged invalid while other
 compilers does successfully execute the same code. Does it mean one has
 to pass some special options to gfortran to produce the right result.
 Thanks.

The code has a bug.  It's not gfortran's fault that it doesn't work with
gfortran.  'sa' is an array in that code.  It is accessed out of bounds in the
loop of the main program.  This is caught at runtime, if the code is compiled
with '-fbounds-check'.  The problem only appears on i686 by hazard.  'The code
works if compiled with other compilers' doesn't mean 'the code is correct and
bug-free', unfortunately.

If you're still not convinced, lean back, look at the following five lines of
code (which are extracted from your testcase), and try to figure out what the
code means for all possible values of 'i'.
  parameter(n=8)
  real sa(n)
  do 20,i=1,2*n-1,2
 sa(i)=a(i)**2+a(i+1)**2
 20   continue

Regards,
- Tobi

ps I think you really want that loop to look like
  do i=2, 2*n, 2
  sa(i/2) = a(i-1)**2 + a(i)**2
  end do
or something similar.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18998


[Bug fortran/18998] Gfortran produces wrong output (c/f to g77)

2004-12-16 Thread Thomas dot Koenig at online dot de

--- Additional Comments From Thomas dot Koenig at online dot de  2004-12-16 
11:47 ---
The code runs correctly on IA-64.

$ gfortran fft2.for
$ ./a.out
   0.00   0.00
   0.00   0.00
   4.00   0.00
   0.00   0.00
   0.00   0.00
   0.00   0.00
   4.00   0.00
   0.00   0.00
STOP 0
$ gfortran -O3 fft2.for
$ ./a.out
   0.00   0.00
   0.00   0.00
   4.00   0.00
   0.00   0.00
   0.00   0.00
   0.00   0.00
   4.00   0.00
   0.00   0.00
STOP 0
For comparison:
$ ifort fft2.for
$ ./a.out
  0.000E+00  0.000E+00
  0.000E+00  0.000E+00
   4.00  0.000E+00
  0.000E+00  0.000E+00
  0.000E+00  0.000E+00
  0.000E+00  0.000E+00
   4.00  0.000E+00
  0.000E+00  0.000E+00
$ gfortran -v
Reading specs from /home/zfkts/lib/gcc/ia64-unknown-linux-gnu/4.0.0/specs
Configured with: ../gcc-4.0-20041212/configure --prefix=/home/zfkts
--enable-languages=c,c++,f95 : (reconfigured) ../gcc-4.0-20041212/configure
--prefix=/home/zfkts --enable-languages=c,c++,f95 --disable-shared
Thread model: posix
gcc version 4.0.0 20041212 (experimental)


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18998


[Bug fortran/18998] Gfortran produces wrong output (c/f to g77)

2004-12-14 Thread pinskia at gcc dot gnu dot org

--- Additional Comments From pinskia at gcc dot gnu dot org  2004-12-14 
19:40 ---
This works for me on ppc-darwin with gcc 4.0.0 (20041214).

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18998


[Bug fortran/18998] Gfortran produces wrong output (c/f to g77)

2004-12-14 Thread tobi at gcc dot gnu dot org

--- Additional Comments From tobi at gcc dot gnu dot org  2004-12-14 22:29 
---
I'm seeing the same result as Deji on i686-pc-linux.

[EMAIL PROTECTED] tests]$ gfortran --version
GNU Fortran 95 (GCC 4.0.0 20041210 (experimental))
Copyright (C) 2004 Free Software Foundation, Inc.

GNU Fortran comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of GNU Fortran
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING


-- 
   What|Removed |Added

 Status|UNCONFIRMED |NEW
 Ever Confirmed||1
   Last reconfirmed|-00-00 00:00:00 |2004-12-14 22:29:23
   date||


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18998


[Bug fortran/18998] Gfortran produces wrong output (c/f to g77)

2004-12-14 Thread deji_aking at yahoo dot ca

--- Additional Comments From deji_aking at yahoo dot ca  2004-12-14 19:30 
---
Created an attachment (id=7744)
 -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=7744action=view)
FFT code


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18998


[Bug fortran/18998] Gfortran produces wrong output (c/f to g77)

2004-12-14 Thread deji_aking at yahoo dot ca

--- Additional Comments From deji_aking at yahoo dot ca  2004-12-14 20:06 
---
(In reply to comment #2)
 This works for me on ppc-darwin with gcc 4.0.0 (20041214).

I should add that I noticed the problem with gcc 4.0.0 (20041211) on FC3

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18998


[Bug fortran/18998] Gfortran produces wrong output (c/f to g77)

2004-12-14 Thread deji_aking at yahoo dot ca

--- Additional Comments From deji_aking at yahoo dot ca  2004-12-14 20:55 
---
(In reply to comment #4)

  I should add that I noticed the problem with gcc 4.0.0 (20041211) on FC3
 
 That still does not give enough information.  What target is this, x86?

Yes. I thought I put that in the original bug report.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18998


[Bug fortran/18998] Gfortran produces wrong output (c/f to g77)

2004-12-14 Thread sgk at troutmask dot apl dot washington dot edu

--- Additional Comments From sgk at troutmask dot apl dot washington dot 
edu  2004-12-14 20:35 ---
The compiles and runs correctly on amd64-*-FreeBSD.

-- 
steve

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18998