Bug 24878 - subroutine getting called illegally as a function
Summary: subroutine getting called illegally as a function
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.1.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2005-11-15 19:11 UTC by Uttam Pawar
Modified: 2018-01-05 11:50 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-01-05 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Uttam Pawar 2005-11-15 19:11:21 UTC
This test is taken from, http://ftp.cac.psu.edu/pub/ger/fortran/test/test10.for

$ cat test.f90
        INTEGER X, Y, SUBA
        EXTERNAL SUBA
        X=-1
        Y=-2
        CALL ANY(SUBA,X,Y)
        WRITE(*,*)'Did NOT catch this error'
        PAUSE
        STOP
        END
        SUBROUTINE ANY(FNC,X,Y)
        INTEGER Y,X, FNC
!---FNC is not a Function subprogram so calling it
!   as a function is an error.
        Y=FNC(X)
        RETURN
        END
        SUBROUTINE SUBA(X)
        INTEGER X
        X=12345
        RETURN
        END

$ gfrotran test.f90
$ ./a.out
in suba
 Did NOT catch this error
PAUSE
To resume execution, type go.  Other input will terminate the job.
go
RESUMED

In this test case, a subroutine SUBA is getting called as a function which should have been caught at runtime.
Comment 1 Andrew Pinski 2005-11-15 19:45:33 UTC
Confirmed, but minor since a lot of the other fortran implemenations don't detect it either.
Comment 2 David Edelsohn 2006-01-03 16:29:09 UTC
Not powerpc-specific.
Comment 3 Dominique d'Humieres 2009-04-14 12:20:40 UTC
At revision 145996, this error is not detected with the -fwhole-file option:

[karma] f90/bug% gfc -fwhole-file pr24878_db.f90
[karma] f90/bug% a.out 
 Did NOT catch this error

Comment 4 Thomas Koenig 2018-01-05 11:50:12 UTC
Still no error issues, not even with -flto.