public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/54389] New: [F2003/F2008 difference] PURE functions and pointer dummy arguments
@ 2012-08-28  8:10 burnus at gcc dot gnu.org
  2012-08-28  8:40 ` [Bug fortran/54389] [F2003/F2008 difference] PURE functions and pointer dummy arguments / DECL_PURE_P issue burnus at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-08-28  8:10 UTC (permalink / raw)
  To: gcc-bugs

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


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

end of thread, other threads:[~2024-04-22 19:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-28  8:10 [Bug fortran/54389] New: [F2003/F2008 difference] PURE functions and pointer dummy arguments burnus at gcc dot gnu.org
2012-08-28  8:40 ` [Bug fortran/54389] [F2003/F2008 difference] PURE functions and pointer dummy arguments / DECL_PURE_P issue burnus at gcc dot gnu.org
2012-08-28 18:18 ` burnus at gcc dot gnu.org
2012-09-12 10:01 ` Joost.VandeVondele at mat dot ethz.ch
2012-09-12 10:30 ` burnus at gcc dot gnu.org
2012-09-13 19:49 ` burnus at gcc dot gnu.org
2015-10-20 14:14 ` dominiq at lps dot ens.fr
2024-04-22 19:45 ` anlauf at gcc dot gnu.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).