From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by sourceware.org (Postfix) with ESMTP id 401CF385AC1C for ; Tue, 10 Aug 2021 12:49:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 401CF385AC1C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=kernel.crashing.org Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 17ACm7HM016091; Tue, 10 Aug 2021 07:48:07 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 17ACm6Cl016090; Tue, 10 Aug 2021 07:48:06 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Tue, 10 Aug 2021 07:48:06 -0500 From: Segher Boessenkool To: Bill Schmidt 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 Message-ID: <20210810124806.GH1583@gate.crashing.org> References: <5394facbf34d21fab7944808ccb27dca74f6f51f.1627562851.git.wschmidt@linux.ibm.com> <20210807000158.GZ1583@gate.crashing.org> <9842d456-9003-8cbf-0e13-40821ae4217c@linux.ibm.com> <20210808202710.GC1583@gate.crashing.org> <3b2a741c-5e94-3689-833a-6bb2be366adf@linux.ibm.com> <0175e9b9-d0a7-f0c2-89b3-230251a1bf80@linux.ibm.com> <20210809234458.GF1583@gate.crashing.org> <188d0a99-4382-39cd-fb4e-3ccacd63c010@linux.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <188d0a99-4382-39cd-fb4e-3ccacd63c010@linux.ibm.com> User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-5.7 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, TXREP, T_SPF_HELO_PERMERROR, T_SPF_PERMERROR autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Aug 2021 12:49:09 -0000 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 :-) Segher