public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/47984] Pointer dummy argument mismatch not detected by Fortran compiler
Date: Fri, 04 Mar 2011 19:40:00 -0000	[thread overview]
Message-ID: <bug-47984-4-4owlYRP7Cf@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-47984-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47984

--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-03-04 19:39:32 UTC ---
(In reply to comment #3)
> Sorry, I don't understand why you consider the bug report invalid.
> You may very well be correct, but please explain. I am not such a
> Fortran expert, so I may have missed something here.


I thought the error message (with -std=f2003) in comment 1 was rather clear,
seemingly that's not the case:


    call testsub(a%i)
                 1
Error: Fortran 2008: Non-pointer actual argument at (1) to pointer dummy 'p'


That means: It is allowed in Fortran 2008, but not before. (See below for the
details.)


  * * *


If one looks into the Fortran 2008 standard
(http://gcc.gnu.org/wiki/GFortranStandards), one finds the following:


"12.5.2.7 Pointer dummy variables"


"If the dummy argument does not have the INTENT (IN), the actual argument shall
be a pointer. Otherwise, the actual argument shall be a pointer or a valid
target for the dummy pointer in a pointer assignment statement. If the actual
argument is not a pointer, the dummy pointer becomes pointer associated with
the actual argument."


Thus, the crucial points are:

(a) the dummy argument has INTENT(IN) - which "p" has
(b) the actual argument has the TARGET attribute which "a" and thus "a%i" has


The INTENT(IN) for the pointer ensures that the pointer association is not
modified -- and TARGET avoids alias issues. Thus, there is no technical reason
for not allowing it -- which the standardization committee seemingly also
realized. Thus, it is now allowed in Fortran 2008.

 * * *

For an overview about the new Fortran 2008 features, see also
  ftp://ftp.nag.co.uk/sc22wg5/N1801-N1850/N1828.pdf

For the already implemented F2008 features, see
  http://gcc.gnu.org/wiki/Fortran2008Status
or in the release notes:
  http://gcc.gnu.org/wiki/GFortran#news
  http://gcc.gnu.org/gcc-4.6/changes.html


  parent reply	other threads:[~2011-03-04 19:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-04  8:31 [Bug fortran/47984] New: " thenlich at users dot sourceforge.net
2011-03-04 15:47 ` [Bug fortran/47984] " kargl at gcc dot gnu.org
2011-03-04 17:10 ` burnus at gcc dot gnu.org
2011-03-04 18:58 ` thenlich at users dot sourceforge.net
2011-03-04 19:16 ` sgk at troutmask dot apl.washington.edu
2011-03-04 19:40 ` burnus at gcc dot gnu.org [this message]
2011-03-07  6:26 ` thenlich at users dot sourceforge.net

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-47984-4-4owlYRP7Cf@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).