Bug 15151 - [g77] incorrect logical i/o in 64-bit mode
Summary: [g77] incorrect logical i/o in 64-bit mode
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libf2c (show other bugs)
Version: 3.3.3
: P2 normal
Target Milestone: 3.4.1
Assignee: Not yet assigned to anyone
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2004-04-26 15:31 UTC by Roger Hill-Cottingham
Modified: 2004-06-19 15:53 UTC (History)
3 users (show)

See Also:
Host: sparc-sun-solaris2.8
Target: sparc-sun-solaris2.8
Build: sparc-sun-solaris2.8
Known to work:
Known to fail:
Last reconfirmed: 2004-04-30 15:45:21


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Roger Hill-Cottingham 2004-04-26 15:31:57 UTC
$ cat pox.f
      LOGICAL LL
      LL=.TRUE.
      IF (LL) THEN
        WRITE(*,*)'TRUE ',LL
      ELSE
        WRITE(*,*)'FALSE ',LL
      ENDIF
      STOP
      END


When compiled with:
$ /usr/local/gcc-3.3.3/bin/g77 -Wall -m64 -o pox pox.f
produces an executable that is linked thus:
$ ldd ./pox
        libg2c.so.0 =>   /usr/local/gcc-3.3.3/lib/sparcv9//libg2c.so.0
        libm.so.1 =>     /usr/lib/64/libm.so.1
        libgcc_s.so.1 =>         /usr/local/gcc-3.3.3/lib/sparcv9//libgcc_s.so.1
        libc.so.1 =>     /usr/lib/64/libc.so.1
        libdl.so.1 =>    /usr/lib/64/libdl.so.1
        /usr/platform/SUNW,Sun-Blade-100/lib/sparcv9/libc_psr.so.1
and produces this output:
$ ./pox
 TRUE  F

If compiled without the -m64 flag, and the environment variable LD_LIBRARY_PATH
is changed to /usr/local/gcc-3.3.3/lib (from /usr/local/gcc-3.3.3/lib/sparcv9)
then the output is correct:
$ ./pox
 TRUE  T
$ ldd ./pox
        libg2c.so.0 =>   /usr/local/gcc-3.3.3/lib//libg2c.so.0
        libm.so.1 =>     /usr/lib/libm.so.1
        libgcc_s.so.1 =>         /usr/local/gcc-3.3.3/lib//libgcc_s.so.1
        libc.so.1 =>     /usr/lib/libc.so.1
        libdl.so.1 =>    /usr/lib/libdl.so.1
        /usr/platform/SUNW,Sun-Blade-100/lib/libc_psr.so.1


gcc built with:
../gcc-3.3.3/configure --prefix=/usr/local/gcc-3.3.3 \
 --enable-languages=c,fortran,c++
make bootstrap
su
umask 022
make install
Comment 1 Andrew Pinski 2004-04-27 21:09:24 UTC
Can you test 3.4.0?
Comment 2 Andrew Pinski 2004-04-27 21:09:32 UTC
Can you test 3.4.0?
Comment 3 bdavis9659 2004-04-28 00:33:56 UTC
this snippet of code in wrtfmt.c looks suspect.   

wrt_L (Uint * n, int len, ftnlen sz)
{
  int i;
  long x;
  if (sizeof (long) == sz)
    x = n->il;
  else if (sz == sizeof (char))
    x = n->ic;
  else
    x = n->is;

maybe should be something like this:

if (sizeof (long) == sz)
    x = n->il;
else if (sz == sizeof (longint)
   x = n->ili
....

i do not have access to a SPARC system to debug this, but this may (or may not:)
help someone else looking at this.


regards,
bud davis
 
Comment 4 Roger Hill-Cottingham 2004-04-30 15:11:57 UTC
(In reply to comment #2)
> Can you test 3.4.0?

Yes, and I get the same response:

$ /usr/local/gcc-3.4.0/bin/g77 -m64 -o pox pox.f
$ export LD_LIBRARY_PATH=/usr/local/gcc-3.4.0/lib/sparcv9 
$ ./pox
 TRUE  F

Roger.
Comment 5 Andrew Pinski 2004-04-30 15:20:23 UTC
Okay thanks, I do not know if this is going to be fixed for g77 but it is already fixed if I read the source 
correctly for gfortran so suspending as fixed on the tree-ssa (which is the branch where gfortran is 
located right now).
Comment 6 Wolfgang Bangerth 2004-04-30 15:45:20 UTC
Since 3.4.x is the last release branch on which g77 will be supported, 
it may make sense to fix it there even if it is not a regression. Let's 
let one of the g77 maintainers comment on this first, before we suspend 
this PR. 
 
W. 
Comment 7 Eric Botcazou 2004-05-02 07:49:27 UTC
> i do not have access to a SPARC system to debug this, but this may (or may
> not:) help someone else looking at this.

I tried your patch but it doesn't seem to help.  I also tried:

Index: wrtfmt.c
===================================================================
RCS file: /cvs/gcc/gcc/libf2c/libI77/wrtfmt.c,v
retrieving revision 1.7
diff -u -r1.7 wrtfmt.c
--- wrtfmt.c    2 Jun 2002 13:01:12 -0000       1.7
+++ wrtfmt.c    2 May 2004 07:42:27 -0000
@@ -251,11 +251,15 @@
 wrt_L (Uint * n, int len, ftnlen sz)
 {
   int i;
-  long x;
+  longint x;
   if (sizeof (long) == sz)
     x = n->il;
   else if (sz == sizeof (char))
     x = n->ic;
+#ifdef Allow_TYQUAD
+  else if (sz == sizeof (longint))
+    x = n->ili;
+#endif
   else
     x = n->is;
   for (i = 0; i < len - 1; i++)

with the same result.
Comment 8 bdavis9659 2004-05-06 11:33:06 UTC
proposed patch:

http://gcc.gnu.org/ml/fortran/2004-05/msg00038.html
Comment 9 Mark Mitchell 2004-06-14 17:24:51 UTC
I've removed the target milestone, as this is not a regression.

Toon -- that said, if you want to review and apply this patch for 3.4.1, go ahead.
Comment 10 Toon Moene 2004-06-19 11:12:52 UTC
Fixed from 3.4.1 onwards by applying Bud Davis' patch to the 3.4 branch.

Thanks, Bud !