public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: "N.M. Maclaren" <nmm1@cam.ac.uk>
To: "Bader, Reinhold" <Reinhold.Bader@lrz.de>
Cc: Thomas Koenig <tkoenig@netcologne.de>,
	   "fortran@gcc.gnu.org" <fortran@gcc.gnu.org>
Subject: Re: AW: [patch,wip] warn on noncontiguous pointers
Date: Fri, 28 Sep 2018 16:59:00 -0000	[thread overview]
Message-ID: <Prayer.1.3.5.1809281759190.27715@hermes-2.csi.cam.ac.uk> (raw)
In-Reply-To: <2e72ca261ac34d0b839c112f8cee3600@lrz.de>

On Sep 28 2018, Bader, Reinhold wrote:
>> 
>> >> If we go down the list, we see that fptr1(4:) is not contiguous; it
>> >> is not an array (it is a pointer), so (4) also does not apply.
>> > I don't agree with this conclusion. First, the array and pointer
>> > properties are not mutually exclusive (they are conveyed by specifying
>> > the DIMENSION and POINTER attribute, independently).
>> 
>> Can you maybe elaborate a bit more?
>> 
>> I see that you can associate a pointer with a target (6.7.1.4), which 
>> of course can be an array. But I have not found anything in the standard 
>> that says that a pointer to an array is an array.
>
> OK. Looking at 5.3.8.1 (Fortran 2008 for the sake of this discussion), we 
> have that an object that has the DIMENSION attribute is an array. 
> array-spec includes deferred-shape-spec-list, so any object declared with 
> deferred shape is an array.
>
> 5.3.8.4 then says C532 An array with the POINTER or ALLOCATABLE attribute 
> shall have an array-spec that is a deferred-shape-spec-list.
>
> and then has further text to say at what point things like SHAPE or SIZE 
> of such an object become defined.
>
>It can't get any clearer than that. 

My guess is that the root cause of the confusion is the phrasing 'pointer 
to an array', because that implies a model in which the pointer is 
separate. It's better called an array pointer, where the two properties are 
inseparable (for that name), and the comment "it is not an array (it is a 
pointer)" is not correct - it's both. Attributes are not qualifiers in the 
C sense.

That's why several of us who teach Fortran tell C and C++ programmers that
they will first have to unlearn much of what they know - the language's
abstract model is extremely different!


Regards,
Nick Maclaren.


  reply	other threads:[~2018-09-28 16:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-27  8:00 Bader, Reinhold
2018-09-27 17:23 ` Thomas Koenig
2018-09-28  5:12   ` AW: " Bader, Reinhold
2018-09-28 16:59     ` N.M. Maclaren [this message]
2018-09-30 18:12     ` Thomas Koenig
2018-10-01 13:36       ` Cesar Philippidis
2018-10-03 21:16       ` Cesar Philippidis
2018-10-05  6:14         ` Thomas Koenig

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=Prayer.1.3.5.1809281759190.27715@hermes-2.csi.cam.ac.uk \
    --to=nmm1@cam.ac.uk \
    --cc=Reinhold.Bader@lrz.de \
    --cc=fortran@gcc.gnu.org \
    --cc=tkoenig@netcologne.de \
    /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).