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


Hi,

It appears that g77 always converts a real function return value to double precision. The following program illustrates this:

      REAL FUNCTION FOO()
      RFROMC = 50.0
      RETURN
      END

Compiled with g77 -S -O produces the following assembly:

        .file   "foo.f"
        .text
.globl foo_
        .type   foo_, @function
foo_:
.LFB2:
        cvtss2sd        %xmm0, %xmm0
        ret
.LFE2:
        .size   foo_, .-foo_
        .section        .eh_frame,"a",@progbits
.Lframe1:
        .long   .LECIE1-.LSCIE1
.LSCIE1:
        .long   0x0
        .byte   0x1
        .string ""
        .uleb128 0x1
        .sleb128 -8
        .byte   0x10
        .byte   0xc
        .uleb128 0x7
        .uleb128 0x8
        .byte   0x90
        .uleb128 0x1
        .align 8
.LECIE1:
.LSFDE1:
        .long   .LEFDE1-.LASFDE1
.LASFDE1:
        .long   .LASFDE1-.Lframe1
        .quad   .LFB2
        .quad   .LFE2-.LFB2
        .align 8
.LEFDE1:
        .ident  "GCC: (GNU) 3.3.1 (SuSE Linux)"


The cvtss2sd converts the single precision value to a double precision value before returning it. This problem still occurs when you declare the return value REAL*4. This bug does not cause any serious problems when the user is only using g77 to compile their programs. But when they mix g77-generated code with code from another FORTRAN compiler, the non-g77 compiler cannot correctly call the real function unless its return value is declared REAL*8.


So, as a work around, g77 real functions should be declared REAL*8.

Regards,

Mark





--
Mark Leair - Software Engineer                   mark.leair@st.com
Advanced Compilers & Tools                       Ph: +1-503-682-2806
AST Portland Laboratory, STMicroelectronics      Fx: +1-503-682-2637
Wilsonville, OR 97070 USA


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