From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25822 invoked by alias); 28 Aug 2012 08:10:53 -0000 Received: (qmail 25794 invoked by uid 22791); 28 Aug 2012 08:10:49 -0000 X-SWARE-Spam-Status: No, hits=-3.6 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; Tue, 28 Aug 2012 08:10:36 +0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/54389] New: [F2003/F2008 difference] PURE functions and pointer dummy arguments Date: Tue, 28 Aug 2012 08:10:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: diagnostic, rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org 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 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: 2012-08/txt/msg01833.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54389 Bug #: 54389 Summary: [F2003/F2008 difference] PURE functions and pointer dummy arguments Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Keywords: diagnostic, rejects-valid Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned@gcc.gnu.org ReportedBy: burnus@gcc.gnu.org Broad up in the comp.lang.fortran "Function questions?" thread https://groups.google.com/forum/?fromgroups=#!topic/comp.lang.fortran/r4PVbtaBnFM Ian Harvey remarks there that Fortran 2008 removed a restriction regarding PURE. Fortran 2003 has: "C1272 In a pure subprogram any designator with a base object that [...] is a dummy argument of a pure function, is a dummy argument with INTENT (IN) of a pure subroutine [...] shall not be used in the following contexts: [...]" Fortran 2008 changed it to: "C1283 In a pure subprogram any designator with a base object that [...] is a dummy argument with the INTENT (IN) attribute [...] shall not be used [...]" Note: Both standards (F2003:C1266, F2008:C1276) require that all *nonpointer* dummy arguments to pure *functions* have the INTENT(IN) or VALUE attribute. However, there is no such restriction for pointers. Hence, an INTENT(OUT) or INTENT(INOUT) pointer is allowed - also for functions - and it may be used in pointer assignments (both sides), variable definition contexts etc. - like in a normal procedure. Currently, the following program is rejected with: Error: Variable 'ptr' can not appear in a variable definition context (assignment) at (1) in PURE procedure (As a side remark: I wonder whether it should be made clearer that this applies to a pure FUNCTION rather than to a pure SUBROUTINE. And the error message feels a bit incomplete, maybe one should add the procedure name at the end.) PURE INTEGER FUNCTION foo (ptr) INTEGER, INTENT(INOUT), POINTER :: ptr ptr = ptr + 1 foo = 1 END FUNCTION foo