This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

[Bug translation/15397] New: c float function called from fortran gives wrong result


This bug is specific for the x86_64 architecture. On 32 bit architectures it
does not occur.


[lx64 16:27] ~/test/cernlib/x86_64 > gcc -v -save-temps -O test1.f funct2.c
-lg2c -lfrtbegin
Reading specs from
/afs/ifh.de/@sys/products/gcc/3.4.0/bin/../lib/gcc/x86_64-unknown-linux-gnu/3.4.0/specs
Configured with: /usr/src/packages/BUILD/gcc-3.4.0/configure 
--prefix=/opt/products/gcc/3.4.0 --enable-shared --enable-cpp
--enable-threads=posix --enable-languages=c,c++,f77,java
--with-local-prefix=/opt/products/gcc/3.4.0
--with-gxx-include-dir=/opt/products/gcc/3.4.0/include/g++-3
Thread model: posix
gcc version 3.4.0
 /afs/ifh.de/@sys/products/gcc/3.4.0/bin/../libexec/gcc/x86_64-unknown-linux-gnu/3.4.0/f771
test1.f -quiet -dumpbase test1.f -mtune=k8 -auxbase test1 -O -version -o test1.s
GNU F77 version 3.4.0 (x86_64-unknown-linux-gnu)
        compiled by GNU C version 3.4.0.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
 as -V -Qy -o test1.o test1.s
GNU assembler version 2.14.90.0.5 (x86_64-suse-linux) using BFD version
2.14.90.0.5 20030722 (SuSE Linux)
 /afs/ifh.de/@sys/products/gcc/3.4.0/bin/../libexec/gcc/x86_64-unknown-linux-gnu/3.4.0/cc1
-E -quiet -v -iprefix
/afs/ifh.de/@sys/products/gcc/3.4.0/bin/../lib/gcc/x86_64-unknown-linux-gnu/3.4.0/
funct2.c -mtune=k8 -O -o funct2.i
ignoring nonexistent directory
"/afs/ifh.de/@sys/products/gcc/3.4.0/bin/../lib/gcc/x86_64-unknown-linux-gnu/3.4.0/../../../../x86_64-unknown-linux-gnu/include"
ignoring duplicate directory
"/opt/products/gcc/3.4.0/lib/gcc/x86_64-unknown-linux-gnu/3.4.0/include"
ignoring nonexistent directory
"/opt/products/gcc/3.4.0/lib/gcc/x86_64-unknown-linux-gnu/3.4.0/../../../../x86_64-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /afs/ifh.de/@sys/products/gcc/3.4.0/bin/../lib/gcc/x86_64-unknown-linux-gnu/3.4.0/include
 /opt/products/gcc/3.4.0/include
 /usr/include
End of search list.
 /afs/ifh.de/@sys/products/gcc/3.4.0/bin/../libexec/gcc/x86_64-unknown-linux-gnu/3.4.0/cc1
-fpreprocessed funct2.i -quiet -dumpbase funct2.c -mtune=k8 -auxbase funct2 -O
-version -o funct2.s
GNU C version 3.4.0 (x86_64-unknown-linux-gnu)
        compiled by GNU C version 3.4.0.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
 as -V -Qy -o funct2.o funct2.s
GNU assembler version 2.14.90.0.5 (x86_64-suse-linux) using BFD version
2.14.90.0.5 20030722 (SuSE Linux)
 /afs/ifh.de/@sys/products/gcc/3.4.0/bin/../libexec/gcc/x86_64-unknown-linux-gnu/3.4.0/collect2
--eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2
/usr/lib/../lib64/crt1.o /usr/lib/../lib64/crti.o
/afs/ifh.de/@sys/products/gcc/3.4.0/bin/../lib/gcc/x86_64-unknown-linux-gnu/3.4.0/crtbegin.o
-L/afs/ifh.de/@sys/products/gcc/3.4.0/bin/../lib/gcc/x86_64-unknown-linux-gnu/3.4.0
-L/afs/ifh.de/@sys/products/gcc/3.4.0/bin/../lib/gcc
-L/opt/products/gcc/3.4.0/lib/gcc/x86_64-unknown-linux-gnu/3.4.0
-L/afs/ifh.de/@sys/products/gcc/3.4.0/bin/../lib/gcc/x86_64-unknown-linux-gnu/3.4.0/../../../../lib64
-L/afs/ifh.de/@sys/products/gcc/3.4.0/bin/../lib/gcc/x86_64-unknown-linux-gnu/3.4.0/../../..
-L/opt/products/gcc/3.4.0/lib/gcc/x86_64-unknown-linux-gnu/3.4.0/../../../../lib64
-L/opt/products/gcc/3.4.0/lib/gcc/x86_64-unknown-linux-gnu/3.4.0/../../..
-L/lib/../lib64 -L/usr/lib/../lib64 test1.o funct2.o -lg2c -lfrtbegin -lgcc
-lgcc_eh -lc -lgcc -lgcc_eh
/afs/ifh.de/@sys/products/gcc/3.4.0/bin/../lib/gcc/x86_64-unknown-linux-gnu/3.4.0/crtend.o
/usr/lib/../lib64/crtn.o

example code

test1.f:

      program test
*
*     error connected with return value from c routines
*
      implicit none
*
      real funct1, funct2, retval
      integer funct3, iretval

*     for calling a fortran function
      retval  = funct1 (1.1111)
      print *, 'in test1: retval from fortran call is ', retval
      retval  = funct2 (1.1111)
      print *, 'in test1: retval from c(float) call is ', retval
      iretval = funct3 (2)
      print *, 'in test1: retval from c(int)   call is ', iretval
      stop

      end

      real function funct1 ( inval )

      implicit none

      real inval, retval

      retval = inval
      print *, 'funct1: return value = ', retval
      funct1 = retval

      end

funct2.c:

float funct2_( float* value ) {
  float retval = *value ;
  printf ("funct2: return value = %f\n", retval);
  return retval ;
}
int funct3_( int* value ) {
  int retval = *value ;
  printf ("funct2: return value = %d\n", retval);
  return retval ;
}

Job output:
[lx64 16:45] ~/test/cernlib/x86_64 > ./a.out
 funct1: return value =   1.11109996
 in test1: retval from fortran call is   1.11109996
funct2: return value = 1.111100
 in test1: retval from c(float) call is   0.
funct2: return value = 2
 in test1: retval from c(int)   call is  2

-- 
           Summary: c float function called from fortran gives wrong result
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: critical
          Priority: P1
         Component: translation
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: harald dot vogt at desy dot de
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: x86_64 GNU/Linux
  GCC host triplet: x86_64 GNU/Linux
GCC target triplet: x86_64 GNU/Linux


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


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