public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Sandiford <richard.sandiford@arm.com>
To: Joseph Myers <joseph@codesourcery.com>
Cc: "Uecker\, Martin" <Martin.Uecker@med.uni-goettingen.de>,
		"gcc-patches\@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
	 "jason\@redhat.com"	<jason@redhat.com>,
	 "nathan\@acm.org" <nathan@acm.org>
Subject: Re: [00/10][RFC] Splitting the C and C++ concept of "complete type"
Date: Thu, 18 Oct 2018 13:33:00 -0000	[thread overview]
Message-ID: <87sh138lq9.fsf@arm.com> (raw)
In-Reply-To: <alpine.DEB.2.21.1810171427170.14713@digraph.polyomino.org.uk>	(Joseph Myers's message of "Wed, 17 Oct 2018 14:35:04 +0000")

Joseph Myers <joseph@codesourcery.com> writes:
> On Wed, 17 Oct 2018, Richard Sandiford wrote:
>> Yeah, can't deny that if you look at it as a general-purpose extension.
>> But that's not really what this is supposed to be.  It's fairly special
>> purpose: there has to be some underlying variable-length/sizeless
>> built-in type that you want to provide via a library.
>> 
>> What the extension allows is enough to support the intended use case,
>> and it does that with no enforced overhead.
>
> Part of my point is that there are various *other* possible cases of 
> non-VLA-variable-size-type people have suggested in WG14 reflector 
> discussions - so any set of concepts for such types ought to take into 
> account more than just the SVE use case (even if other use cases need 
> further concepts added on top of the ones needed for SVE).

[Answered this in the other thread -- sorry, took me a while to go
through the full discussion.]

>> > Surely, the processor knows the size when it computes using these
>> > types, so one could make it available using 'sizeof'.
>> 
>> The argument's similar here: we don't really need sizeof to be available
>> for vector use because the library provides easy ways of getting
>> vector-length-based constants.  Usually what you want to know is
>> "how many elements of type X are there?", with bytes just being one
>> of the available element sizes.
>
> But if having sizeof available makes for a more natural language feature 
> (one where a few places referencing VLAs need to change to reference a 
> more general class of variable-size types, and a few constraints on VLAs 
> and variably modified types need to be relaxed to allow what you want with 
> these types), that may be a case for doing so, even if sizeof won't 
> generally be used.

I agree that might be all that's needed in C.  But since C++ doesn't
even have VLAs yet (and since something less ambituous than VLAs was
rejected) the situation is very different there.

I think we'd need a compelling reason to make sizeof variable in C++.
The fact that it isn't going to be generally used for SVE anyway
would undercut that.

> If the processor in fact knows the size, do you actually need to include 
> it in the object to be able to provide it when sizeof is called?  (With 
> undefined behavior still present if passing the object from a thread with 
> one value of sizeof for that type to a thread with a different value of 
> sizeof for that type, of course - the rule on VLA type compatibility would 
> still need to be extended to apply to sizes of these types, and those they 
> contain, recursively.)

No, if we go the undefined behaviour route, we wouldn't need to store it.
This was just to answer Martin's suggestion that we could make sizeof(x)
do the right thing for a sizeless object x by storing the size with x.

Thanks,
Richard

  reply	other threads:[~2018-10-18 12:48 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-15 14:32 Richard Sandiford
2018-10-15 14:33 ` [01/10] Expand COMPLETE_TYPE_P in obvious checks for null Richard Sandiford
2018-10-18 19:32   ` Jeff Law
2018-10-15 14:34 ` [03/10] Move COMPLETE_OR_VOID_TYPE_P to the C and C++ frontends Richard Sandiford
2018-10-15 14:34 ` [02/10] Replace most uses of COMPLETE_TYPE_P outside the frontends Richard Sandiford
2018-10-15 14:35 ` [04/10] Move COMPLETE_OR_UNBOUND_ARRAY_TYPE_P to the C and C++ frontends Richard Sandiford
2018-10-15 14:36 ` [05/10] Move complete_or_array_type_p " Richard Sandiford
2018-10-15 14:36 ` [06/10] Move COMPLETE_TYPE_P " Richard Sandiford
2018-10-15 14:37 ` [07/10] Use COMPLETE_TYPE_P instead of TYPE_SIZE Richard Sandiford
2018-10-15 14:38 ` [08/10] Add a TYPE_SIZELESS_P property to types Richard Sandiford
2018-10-15 14:50 ` [09/10] C support for sizeless types Richard Sandiford
2018-10-15 15:01 ` [10/10] C++ " Richard Sandiford
2018-10-15 15:14 ` [00/10][RFC] Splitting the C and C++ concept of "complete type" Joseph Myers
2018-10-15 18:57 ` Uecker, Martin
2018-10-16  8:51   ` Richard Biener
2018-10-16 12:55   ` Richard Sandiford
2018-10-16 23:07     ` Joseph Myers
2018-10-17 12:54       ` Richard Sandiford
2018-10-17 14:39         ` Uecker, Martin
2018-10-17 15:06           ` Richard Sandiford
2018-10-17 15:25             ` Joseph Myers
2018-10-18 13:33               ` Richard Sandiford [this message]
2018-10-18 20:06                 ` Uecker, Martin
2018-10-18 20:12                   ` Richard Sandiford
2018-10-18 21:09                     ` Uecker, Martin
2018-10-18 21:05                   ` Joseph Myers
2018-10-17 14:39         ` Joseph Myers
2018-10-18 12:01           ` Richard Sandiford
2018-10-18 20:34             ` Joseph Myers
2018-10-19 12:34               ` Richard Sandiford
2018-10-19 13:42                 ` Joseph Myers
2018-10-16 12:06 Richard Sandiford
2018-10-16 12:10 ` Richard Sandiford

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=87sh138lq9.fsf@arm.com \
    --to=richard.sandiford@arm.com \
    --cc=Martin.Uecker@med.uni-goettingen.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=nathan@acm.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).