Bug 25174 - gfortran ignores explicit return type for functions
Summary: gfortran ignores explicit return type for functions
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.0.2
: P3 major
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-30 01:43 UTC by albertm@uphs.upenn.edu
Modified: 2005-12-06 22:14 UTC (History)
2 users (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description albertm@uphs.upenn.edu 2005-11-30 01:43:07 UTC
gfortran seems to ignore explicit return types of functions.

Example follows:
-----------------------------bug.for--------------------------------
      PROGRAM BUG
      external real function Mfunc
      real*4 X,Y

      X = Xfunc()
      Y = Mfunc()
      write(6,*) X,Y
      stop
      end

      real function Xfunc()
      Xfunc = 17.232
      return 
      end

      real function Mfunc()
      Mfunc = 17.232
      return 
      end
-----------------------------bug.for------------------------------
When run, this gives:
   17.23200      1.0995535E+09
STOP 0

Compilation was:
[...]/gfortran -Wall -o bug bug.for -L[...]/lib64 \
            -Wl,-rpath,[...]/lib64
(Long path names replaced with [...]).

As usual, thank you very much.  The gcc collection is a wonderful
tool.

-Mike
Comment 1 Thomas Koenig 2005-12-06 22:14:03 UTC
(In reply to comment #0)

>       PROGRAM BUG
>       external real function Mfunc

This declares an external symbol called
"realfunctionmfunc" (fixed form), which is
probably not what you intended.

If you replace that line by

      real Mfunc
      external Mfunc

things work.  If you try to compile this in free form
(extension .f95), you get a syntax error.

I'm resolving this as "invalid".  Feel free to re-open it
if you believe that I haven't addressed the issue correctly.

        Thomas
Comment 2 albertm@uphs.upenn.edu 2005-12-06 22:52:58 UTC
Subject: Re:  gfortran ignores explicit return type for
 fun ctions

Thank you very much.  My apologies.  I don't understand Fortran as
well as I should.

Sincerely,
 Mike Albert


On Tue, 6 Dec 2005, tkoenig at gcc dot gnu dot org wrote:

> 
> 
> ------- Comment #1 from tkoenig at gcc dot gnu dot org  2005-12-06 22:14
> -------
> (In reply to comment #0)
> 
> >       PROGRAM BUG
> >       external real function Mfunc
> 
> This declares an external symbol called
> "realfunctionmfunc" (fixed form), which is
> probably not what you intended.
> 
> If you replace that line by
> 
>       real Mfunc
>       external Mfunc
> 
> things work.  If you try to compile this in free form
> (extension .f95), you get a syntax error.
> 
> I'm resolving this as "invalid".  Feel free to re-open it
> if you believe that I haven't addressed the issue correctly.
> 
>         Thomas
> 
> 
> -- 
> 
> tkoenig at gcc dot gnu dot org changed:
> 
>            What    |Removed                     |Added
> ------------------------------------------------------------------------
> ----
>                  CC|                            |tkoenig at gcc dot gnu
> dot
>                    |                            |org
>              Status|UNCONFIRMED                 |RESOLVED
>          Resolution|                            |INVALID
> 
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25174
> 
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.
>