public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Bill Schmidt <wschmidt@linux.ibm.com>
To: Segher Boessenkool <segher@kernel.crashing.org>
Cc: gcc-patches@gcc.gnu.org, dje.gcc@gmail.com, willschm@linux.ibm.com
Subject: Re: [PATCH 03/34] rs6000: Add the rest of the [altivec] stanza to the builtins file
Date: Tue, 10 Aug 2021 08:02:24 -0500	[thread overview]
Message-ID: <031c85bf-a022-a2e2-ac76-4030c6241cc8@linux.ibm.com> (raw)
In-Reply-To: <20210810124806.GH1583@gate.crashing.org>

On 8/10/21 7:48 AM, Segher Boessenkool wrote:
> On Tue, Aug 10, 2021 at 07:17:54AM -0500, Bill Schmidt wrote:
>> On 8/9/21 6:44 PM, Segher Boessenkool wrote:
>>> This is not a documented GCC extension either, and it might even
>>> conflict with the existing void * extension (allowing arithmetic on it,
>>> by defining sizeof(void)).  In either case it is not currently defined.
>>>
>> I'm not sure how you get to this, but all we're doing here is standard C.
> Arithmetic on void* is the GCC extension.  sizeof(void) is 1 as GCC
> extension, instead of being undefined.  Pointer arithmetic is only
> defined for arrays of the type being pointed to, and you cannot have an
> array of void.  You can do this as GCC extension though, it behaves as
> if it was a char* instead.
>
>> x.c:
>>
>> char
>> foo (const void *x)
>> {
>>    const char *y = (const char *) x;
>>    return *y;
>> }
> And this behaves exactly the same if you do s/const void/void/ .  The
> const qualifier is meaningless on things of type void, since you cannot
> have an lvalue of that type anyway.  And all type qualifiers can be cast
> away (or cast into existence).
>
>> y.c:
>>
>> void
>> foo (const void *x, char c)
>> {
>>    const char *y = (const char *) x;
>>    *y = c;
>> }
>>
>> wschmidt@rain6p1:~/src$ gcc -c x.c
>> wschmidt@rain6p1:~/src$ gcc -c y.c
>> y.c: In function 'foo':
>> y.c:5:6: error: assignment of read-only location '*y'
>>     *y = c;
>>        ^
> Yes, *y is an lvalue.  *x is not: *x is an error.
>
>
> It *is* allowed to have a "const void", but it means exactly the same as
> just "void" (you cannot assign to either!)  And, they are compatible
> types, too, (they are the *same* type in fact!), so if you ever would
> treat them differently it would be mightily confusing :-)


The whole point is that this data type is only used for interfaces, as 
shown in the example code.  Nobody wants to define const void as 
anything.  The const serves only as a contract that the pointed-to 
object, no matter what it is cast to, will not be modified.

I think you're over-thinking this. :-)

Bill

>
>
> Segher

  reply	other threads:[~2021-08-10 13:02 UTC|newest]

Thread overview: 84+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-29 13:30 [PATCHv4 00/34] Replace the Power target-specific builtin machinery Bill Schmidt
2021-07-29 13:30 ` [PATCH 01/34] rs6000: Incorporate new builtins code into the build machinery Bill Schmidt
2021-08-04 22:29   ` Segher Boessenkool
2021-08-05 13:47     ` Bill Schmidt
2021-08-05 16:04       ` Segher Boessenkool
2021-07-29 13:30 ` [PATCH 02/34] rs6000: Add gengtype handling to " Bill Schmidt
2021-08-04 22:52   ` Segher Boessenkool
2021-07-29 13:30 ` [PATCH 03/34] rs6000: Add the rest of the [altivec] stanza to the builtins file Bill Schmidt
2021-08-07  0:01   ` Segher Boessenkool
2021-08-08 16:53     ` Bill Schmidt
2021-08-08 20:27       ` Segher Boessenkool
2021-08-08 20:53         ` Bill Schmidt
2021-08-09 18:05           ` Segher Boessenkool
2021-08-09 19:18           ` Bill Schmidt
2021-08-09 23:44             ` Segher Boessenkool
2021-08-10 12:17               ` Bill Schmidt
2021-08-10 12:48                 ` Segher Boessenkool
2021-08-10 13:02                   ` Bill Schmidt [this message]
2021-08-10 13:40                     ` Segher Boessenkool
2021-08-10 13:49                       ` Bill Schmidt
2021-07-29 13:30 ` [PATCH 04/34] rs6000: Add VSX builtins Bill Schmidt
2021-08-10 16:14   ` will schmidt
2021-08-10 17:52   ` Segher Boessenkool
2021-07-29 13:30 ` [PATCH 05/34] rs6000: Add available-everywhere and ancient builtins Bill Schmidt
2021-08-10 16:17   ` will schmidt
2021-08-10 17:34     ` Segher Boessenkool
2021-08-10 21:29       ` Bill Schmidt
2021-08-11 10:29         ` Segher Boessenkool
2021-08-10 18:38   ` Segher Boessenkool
2021-08-10 18:56     ` Bill Schmidt
2021-08-10 20:33       ` Segher Boessenkool
2021-07-29 13:30 ` [PATCH 06/34] rs6000: Add power7 and power7-64 builtins Bill Schmidt
2021-08-10 16:16   ` will schmidt
2021-08-10 17:48     ` Segher Boessenkool
2021-07-29 13:30 ` [PATCH 07/34] rs6000: Add power8-vector builtins Bill Schmidt
2021-08-23 21:28   ` Segher Boessenkool
2021-07-29 13:30 ` [PATCH 08/34] rs6000: Add Power9 builtins Bill Schmidt
2021-08-23 21:40   ` Segher Boessenkool
2021-08-24 14:20     ` Bill Schmidt
2021-08-24 15:38       ` Segher Boessenkool
2021-08-24 16:27         ` Bill Schmidt
2021-07-29 13:30 ` [PATCH 09/34] rs6000: Add more type nodes to support builtin processing Bill Schmidt
2021-08-23 22:15   ` Segher Boessenkool
2021-08-24 14:38     ` Bill Schmidt
2021-07-29 13:30 ` [PATCH 10/34] rs6000: Add Power10 builtins Bill Schmidt
2021-08-23 23:48   ` Segher Boessenkool
2021-07-29 13:30 ` [PATCH 11/34] rs6000: Add MMA builtins Bill Schmidt
2021-08-25 22:56   ` Segher Boessenkool
2021-07-29 13:30 ` [PATCH 12/34] rs6000: Add miscellaneous builtins Bill Schmidt
2021-08-25 22:58   ` Segher Boessenkool
2021-07-29 13:31 ` [PATCH 13/34] rs6000: Add Cell builtins Bill Schmidt
2021-08-25 22:59   ` Segher Boessenkool
2021-07-29 13:31 ` [PATCH 14/34] rs6000: Add remaining overloads Bill Schmidt
2021-08-25 23:27   ` Segher Boessenkool
2021-08-26 12:59     ` Bill Schmidt
2021-08-26 13:58       ` Segher Boessenkool
2021-07-29 13:31 ` [PATCH 15/34] rs6000: Execute the automatic built-in initialization code Bill Schmidt
2021-08-26 23:15   ` Segher Boessenkool
2021-08-27 12:35     ` Bill Schmidt
2021-08-27 12:49       ` Segher Boessenkool
2021-07-29 13:31 ` [PATCH 16/34] rs6000: Darwin builtin support Bill Schmidt
2021-08-27 18:01   ` Segher Boessenkool
2021-07-29 13:31 ` [PATCH 17/34] rs6000: Add sanity to V2DI_type_node definitions Bill Schmidt
2021-08-27 19:27   ` Segher Boessenkool
2021-07-29 13:31 ` [PATCH 18/34] rs6000: Always initialize vector_pair and vector_quad nodes Bill Schmidt
2021-08-27 19:34   ` Segher Boessenkool
2021-07-29 13:31 ` [PATCH 19/34] rs6000: Handle overloads during program parsing Bill Schmidt
2021-08-27 23:07   ` Segher Boessenkool
2021-08-31  3:34     ` Bill Schmidt
2021-07-29 13:31 ` [PATCH 20/34] rs6000: Handle gimple folding of target built-ins Bill Schmidt
2021-07-29 13:31 ` [PATCH 21/34] rs6000: Handle some recent MMA builtin changes Bill Schmidt
2021-07-29 13:31 ` [PATCH 22/34] rs6000: Support for vectorizing built-in functions Bill Schmidt
2021-07-29 13:31 ` [PATCH 23/34] rs6000: Builtin expansion, part 1 Bill Schmidt
2021-07-29 13:31 ` [PATCH 24/34] rs6000: Builtin expansion, part 2 Bill Schmidt
2021-07-29 13:31 ` [PATCH 25/34] rs6000: Builtin expansion, part 3 Bill Schmidt
2021-07-29 13:31 ` [PATCH 26/34] rs6000: Builtin expansion, part 4 Bill Schmidt
2021-07-29 13:31 ` [PATCH 27/34] rs6000: Builtin expansion, part 5 Bill Schmidt
2021-07-29 13:31 ` [PATCH 28/34] rs6000: Builtin expansion, part 6 Bill Schmidt
2021-07-29 13:31 ` [PATCH 29/34] rs6000: Update rs6000_builtin_decl Bill Schmidt
2021-07-29 13:31 ` [PATCH 30/34] rs6000: Miscellaneous uses of rs6000_builtins_decl_x Bill Schmidt
2021-07-29 13:31 ` [PATCH 31/34] rs6000: Debug support Bill Schmidt
2021-07-29 13:31 ` [PATCH 32/34] rs6000: Update altivec.h for automated interfaces Bill Schmidt
2021-07-29 13:31 ` [PATCH 33/34] rs6000: Test case adjustments Bill Schmidt
2021-07-29 13:31 ` [PATCH 34/34] rs6000: Enable the new builtin support Bill Schmidt

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=031c85bf-a022-a2e2-ac76-4030c6241cc8@linux.ibm.com \
    --to=wschmidt@linux.ibm.com \
    --cc=dje.gcc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=segher@kernel.crashing.org \
    --cc=willschm@linux.ibm.com \
    /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).