public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/18998] New: Gfortran produces wrong output (c/f to g77)
@ 2004-12-14 19:29 deji_aking at yahoo dot ca
  2004-12-14 19:30 ` [Bug fortran/18998] " deji_aking at yahoo dot ca
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: deji_aking at yahoo dot ca @ 2004-12-14 19:29 UTC (permalink / raw)
  To: gcc-bugs

I'm sorry the summary seems so vague, I'm not so sure why it's behaving that way.
Executing the attached code (a simple i/o around a numerical recipe FFT
subroutine) produces the following;
[deji@rhema ~]$ gfortran fft2.for -o resu2
[deji@rhema ~]$ ./resu2
   0.000000       0.000000
   0.000000       0.000000
   4.000000       0.000000
   0.000000       0.000000
   0.000000       0.000000
   0.000000       0.000000
   0.000000       4.000000
   0.000000       0.000000
STOP 0
Doing the same using g77 produces;
[deji@rhema ~]$ g77 fft2.for -o resu2
[deji@rhema ~]$ ./resu2
  0.  0.
  0.  0.
  4.  0.
  0.  0.
  0.  0.
  0.  0.
  4.  0.
  0.  0.

The g77 output is actually right and the gfortran one, wrong (swaping the
imaginary part for the real).

-- 
           Summary: Gfortran produces wrong output (c/f to g77)
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: deji_aking at yahoo dot ca
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: i686-pc-linux


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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/18998] Gfortran produces wrong output (c/f to g77)
  2004-12-14 19:29 [Bug fortran/18998] New: Gfortran produces wrong output (c/f to g77) deji_aking at yahoo dot ca
@ 2004-12-14 19:30 ` deji_aking at yahoo dot ca
  2004-12-14 19:40 ` pinskia at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: deji_aking at yahoo dot ca @ 2004-12-14 19:30 UTC (permalink / raw)
  To: gcc-bugs


------- 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=7744&action=view)
FFT code


-- 


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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/18998] Gfortran produces wrong output (c/f to g77)
  2004-12-14 19:29 [Bug fortran/18998] New: Gfortran produces wrong output (c/f to g77) deji_aking at yahoo dot ca
  2004-12-14 19:30 ` [Bug fortran/18998] " deji_aking at yahoo dot ca
@ 2004-12-14 19:40 ` pinskia at gcc dot gnu dot org
  2004-12-14 20:06 ` deji_aking at yahoo dot ca
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-12-14 19:40 UTC (permalink / raw)
  To: gcc-bugs


------- 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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/18998] Gfortran produces wrong output (c/f to g77)
  2004-12-14 19:29 [Bug fortran/18998] New: Gfortran produces wrong output (c/f to g77) deji_aking at yahoo dot ca
  2004-12-14 19:30 ` [Bug fortran/18998] " deji_aking at yahoo dot ca
  2004-12-14 19:40 ` pinskia at gcc dot gnu dot org
@ 2004-12-14 20:06 ` deji_aking at yahoo dot ca
  2004-12-14 20:07 ` pinskia at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: deji_aking at yahoo dot ca @ 2004-12-14 20:06 UTC (permalink / raw)
  To: gcc-bugs


------- 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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/18998] Gfortran produces wrong output (c/f to g77)
  2004-12-14 19:29 [Bug fortran/18998] New: Gfortran produces wrong output (c/f to g77) deji_aking at yahoo dot ca
                   ` (2 preceding siblings ...)
  2004-12-14 20:06 ` deji_aking at yahoo dot ca
@ 2004-12-14 20:07 ` pinskia at gcc dot gnu dot org
  2004-12-14 20:35 ` sgk at troutmask dot apl dot washington dot edu
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-12-14 20:07 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-12-14 20:07 -------
(In reply to comment #3)
> (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

That still does not give enough information.  What target is this, x86?

-- 


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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/18998] Gfortran produces wrong output (c/f to g77)
  2004-12-14 19:29 [Bug fortran/18998] New: Gfortran produces wrong output (c/f to g77) deji_aking at yahoo dot ca
                   ` (3 preceding siblings ...)
  2004-12-14 20:07 ` pinskia at gcc dot gnu dot org
@ 2004-12-14 20:35 ` sgk at troutmask dot apl dot washington dot edu
  2004-12-14 20:55 ` deji_aking at yahoo dot ca
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: sgk at troutmask dot apl dot washington dot edu @ 2004-12-14 20:35 UTC (permalink / raw)
  To: gcc-bugs


------- 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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/18998] Gfortran produces wrong output (c/f to g77)
  2004-12-14 19:29 [Bug fortran/18998] New: Gfortran produces wrong output (c/f to g77) deji_aking at yahoo dot ca
                   ` (4 preceding siblings ...)
  2004-12-14 20:35 ` sgk at troutmask dot apl dot washington dot edu
@ 2004-12-14 20:55 ` deji_aking at yahoo dot ca
  2004-12-14 22:29 ` tobi at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: deji_aking at yahoo dot ca @ 2004-12-14 20:55 UTC (permalink / raw)
  To: gcc-bugs


------- 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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/18998] Gfortran produces wrong output (c/f to g77)
  2004-12-14 19:29 [Bug fortran/18998] New: Gfortran produces wrong output (c/f to g77) deji_aking at yahoo dot ca
                   ` (5 preceding siblings ...)
  2004-12-14 20:55 ` deji_aking at yahoo dot ca
@ 2004-12-14 22:29 ` tobi at gcc dot gnu dot org
  2004-12-16 11:47 ` Thomas dot Koenig at online dot de
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: tobi at gcc dot gnu dot org @ 2004-12-14 22:29 UTC (permalink / raw)
  To: gcc-bugs


------- 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.

[tobi@marktplatz 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|0000-00-00 00:00:00         |2004-12-14 22:29:23
               date|                            |


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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/18998] Gfortran produces wrong output (c/f to g77)
  2004-12-14 19:29 [Bug fortran/18998] New: Gfortran produces wrong output (c/f to g77) deji_aking at yahoo dot ca
                   ` (6 preceding siblings ...)
  2004-12-14 22:29 ` tobi at gcc dot gnu dot org
@ 2004-12-16 11:47 ` Thomas dot Koenig at online dot de
  2004-12-20 22:40 ` tobi at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Thomas dot Koenig at online dot de @ 2004-12-16 11:47 UTC (permalink / raw)
  To: gcc-bugs


------- 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.000000       0.000000
   0.000000       0.000000
   4.000000       0.000000
   0.000000       0.000000
   0.000000       0.000000
   0.000000       0.000000
   4.000000       0.000000
   0.000000       0.000000
STOP 0
$ gfortran -O3 fft2.for
$ ./a.out
   0.000000       0.000000
   0.000000       0.000000
   4.000000       0.000000
   0.000000       0.000000
   0.000000       0.000000
   0.000000       0.000000
   4.000000       0.000000
   0.000000       0.000000
STOP 0
For comparison:
$ ifort fft2.for
$ ./a.out
  0.0000000E+00  0.0000000E+00
  0.0000000E+00  0.0000000E+00
   4.000000      0.0000000E+00
  0.0000000E+00  0.0000000E+00
  0.0000000E+00  0.0000000E+00
  0.0000000E+00  0.0000000E+00
   4.000000      0.0000000E+00
  0.0000000E+00  0.0000000E+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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/18998] Gfortran produces wrong output (c/f to g77)
  2004-12-14 19:29 [Bug fortran/18998] New: Gfortran produces wrong output (c/f to g77) deji_aking at yahoo dot ca
                   ` (8 preceding siblings ...)
  2004-12-20 22:40 ` tobi at gcc dot gnu dot org
@ 2004-12-20 22:40 ` tobi at gcc dot gnu dot org
  2004-12-21  0:04 ` Tobias dot Schlueter at physik dot uni-muenchen dot de
  10 siblings, 0 replies; 12+ messages in thread
From: tobi at gcc dot gnu dot org @ 2004-12-20 22:40 UTC (permalink / raw)
  To: gcc-bugs


------- 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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/18998] Gfortran produces wrong output (c/f to g77)
  2004-12-14 19:29 [Bug fortran/18998] New: Gfortran produces wrong output (c/f to g77) deji_aking at yahoo dot ca
                   ` (7 preceding siblings ...)
  2004-12-16 11:47 ` Thomas dot Koenig at online dot de
@ 2004-12-20 22:40 ` tobi at gcc dot gnu dot org
  2004-12-20 22:40 ` tobi at gcc dot gnu dot org
  2004-12-21  0:04 ` Tobias dot Schlueter at physik dot uni-muenchen dot de
  10 siblings, 0 replies; 12+ messages in thread
From: tobi at gcc dot gnu dot org @ 2004-12-20 22:40 UTC (permalink / raw)
  To: gcc-bugs


------- 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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/18998] Gfortran produces wrong output (c/f to g77)
  2004-12-14 19:29 [Bug fortran/18998] New: Gfortran produces wrong output (c/f to g77) deji_aking at yahoo dot ca
                   ` (9 preceding siblings ...)
  2004-12-20 22:40 ` tobi at gcc dot gnu dot org
@ 2004-12-21  0:04 ` Tobias dot Schlueter at physik dot uni-muenchen dot de
  10 siblings, 0 replies; 12+ messages in thread
From: Tobias dot Schlueter at physik dot uni-muenchen dot de @ 2004-12-21  0:04 UTC (permalink / raw)
  To: gcc-bugs


------- 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


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2004-12-21  0:04 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-14 19:29 [Bug fortran/18998] New: Gfortran produces wrong output (c/f to g77) deji_aking at yahoo dot ca
2004-12-14 19:30 ` [Bug fortran/18998] " deji_aking at yahoo dot ca
2004-12-14 19:40 ` pinskia at gcc dot gnu dot org
2004-12-14 20:06 ` deji_aking at yahoo dot ca
2004-12-14 20:07 ` pinskia at gcc dot gnu dot org
2004-12-14 20:35 ` sgk at troutmask dot apl dot washington dot edu
2004-12-14 20:55 ` deji_aking at yahoo dot ca
2004-12-14 22:29 ` tobi at gcc dot gnu dot org
2004-12-16 11:47 ` Thomas dot Koenig at online dot de
2004-12-20 22:40 ` tobi at gcc dot gnu dot org
2004-12-20 22:40 ` tobi at gcc dot gnu dot org
2004-12-21  0:04 ` Tobias dot Schlueter at physik dot uni-muenchen dot de

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).