public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/26551]  New: gfortran compiles recursive subroutines declared without the RECURSIVE attribute
@ 2006-03-03 19:50 bdtaylo1 at uiuc dot edu
  2006-03-03 20:00 ` [Bug fortran/26551] " pinskia at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: bdtaylo1 at uiuc dot edu @ 2006-03-03 19:50 UTC (permalink / raw)
  To: gcc-bugs

A subroutine or function that calls itself recursively must be declared with
the RECURSIVE attribute.  gfortran should refuse to compile the subroutine
below and return an error indicating that the RECURSIVE attribute must be
specified.

>$ cat sub.f90 
SUBROUTINE SUB()
CALL SUB()
END SUBROUTINE
>$ gfortran -std=f95 -pedantic sub.f90 -c
>$ gfortran -c -v
Using built-in specs.
Target: powerpc-apple-darwin8.1.0
Configured with: ../gcc-4.1-20050611/configure --enable-threads=posix
--enable-languages=c++,f95
Thread model: posix
gcc version 4.1.0 20050611 (experimental)

For comparison, here is output from g95 and xlf90:
>$ g95 -std=f95 -pedantic sub.f90 -c
In file sub.f90:2

CALL SUB()
         1
Error: SUBROUTINE 'sub' at (1) must be RECURSIVE in order to call itself
>$ xlf90 -qsuffix=cpp=f90 -f95 sub.f90 -c
"sub.f90", line 2.6: 1513-126 (S) Recursive calls are only permitted when the
RECUR option is specified or the RECURSIVE keyword is specified.
** sub   === End of Compilation 1 ===
1501-511  Compilation failed for file sub.f90.


On a related note, the limitations on RECURSIVE subroutines and functions
should also be extended to any ENTRY statements within the subprogram.  For
example, the following code is also illegal but gfortran currently accepts it:

>$ cat sub2.f90 
SUBROUTINE SUB2()
ENTRY ENT2()
CALL ENT2()
END SUBROUTINE
>$ gfortran -std=f95 -pedantic sub2.f90 -c

For comparison, xlf has the following output:
>$ xlf90 -qsuffix=cpp=f90 -f95 sub2.f90 -c
"sub2.f90", line 3.6: 1513-126 (S) Recursive calls are only permitted when the
RECUR option is specified or the RECURSIVE keyword is specified.
** sub2   === End of Compilation 1 ===
1501-511  Compilation failed for file sub2.f90.


-- 
           Summary: gfortran compiles recursive subroutines declared without
                    the RECURSIVE attribute
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bdtaylo1 at uiuc dot edu
 GCC build triplet: powerpc-apple-darwin8.1.0
  GCC host triplet: powerpc-apple-darwin8.1.0
GCC target triplet: powerpc-apple-darwin8.1.0


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2006-05-27  9:07 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-03 19:50 [Bug fortran/26551] New: gfortran compiles recursive subroutines declared without the RECURSIVE attribute bdtaylo1 at uiuc dot edu
2006-03-03 20:00 ` [Bug fortran/26551] " pinskia at gcc dot gnu dot org
2006-03-03 20:02 ` pinskia at gcc dot gnu dot org
2006-03-03 21:05 ` bdtaylo1 at uiuc dot edu
2006-05-07 11:08 ` fxcoudert at gcc dot gnu dot org
2006-05-17 14:12 ` fxcoudert at gcc dot gnu dot org
2006-05-17 14:15 ` fxcoudert at gcc dot gnu dot org
2006-05-27  9:06 ` [Bug fortran/26551] [4.1 only] " fxcoudert at gcc dot gnu dot org
2006-05-27  9:07 ` [Bug fortran/26551] " fxcoudert at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).