This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/49436] New: Modifying actual arguments in subroutine not detected
- From: "tjf at rsc dot anu.edu.au" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 16 Jun 2011 11:13:43 +0000
- Subject: [Bug fortran/49436] New: Modifying actual arguments in subroutine not detected
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49436
Summary: Modifying actual arguments in subroutine not detected
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: tjf@rsc.anu.edu.au
Host: i686-pc-linux-gnu
Created attachment 24544
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24544
Nonconforming code that compiles happily
There's an aspect of the f95 standard that seems to not be enforced by
gfortran.
As I interpret it, the standard says that if an object passed as an actual
argument is also accessible in a subprogram through other means, then this can
only be modified through the corresponding dummy argument (12.4.1.6).
The attached code violates this by modifying a directly inside subroutine c,
rather than through the dummy argument n. With gfortran 4.6.0 on
i686-pc-linux-gnu this nonconforming code compiles happily, even with -Wall
-std=f95 -pedantic.
When run, two 15s are printed despite the value 2 being passed as intent(in)
(clearly the argument is passed by reference).