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: unassig...@gcc.gnu.org
        ReportedBy: t...@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).

Reply via email to