From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24597 invoked by alias); 16 Jun 2011 11:13:58 -0000 Received: (qmail 24583 invoked by uid 22791); 16 Jun 2011 11:13:57 -0000 X-SWARE-Spam-Status: No, hits=-2.7 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 16 Jun 2011 11:13:43 +0000 From: "tjf at rsc dot anu.edu.au" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/49436] New: Modifying actual arguments in subroutine not detected X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: tjf at rsc dot anu.edu.au X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Thu, 16 Jun 2011 11:13:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-06/txt/msg01429.txt.bz2 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).