From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 45887 invoked by alias); 7 Apr 2017 06:47:45 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 45856 invoked by uid 89); 7 Apr 2017 06:47:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-6.9 required=5.0 tests=BAYES_00,GIT_PATCH_1,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 07 Apr 2017 06:47:41 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 3AF61AC19; Fri, 7 Apr 2017 06:47:41 +0000 (UTC) Date: Fri, 07 Apr 2017 06:47:00 -0000 From: Richard Biener To: Bernd Edlinger cc: Florian Weimer , Jakub Jelinek , Jonathan Wakely , GCC Patches , Jason Merrill , Jeff Law Subject: Re: [PATCH] Add a new type attribute always_alias (PR79671) In-Reply-To: Message-ID: References: <20170406075104.GA17461@tucnak> <7d17b3b7-2d38-6184-8bd6-eb9f96f87912@redhat.com> <50936a77-870a-5156-1f5e-b1e0327498b6@redhat.com> <1a0cdc64-3c65-4f2b-427d-8dcb90095cab@redhat.com> <5dee05a9-7606-ee9f-2d3e-d216a5837097@redhat.com> User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-SW-Source: 2017-04/txt/msg00342.txt.bz2 On Thu, 6 Apr 2017, Bernd Edlinger wrote: > On 04/06/17 21:05, Florian Weimer wrote: > > On 04/06/2017 08:49 PM, Bernd Edlinger wrote: > > > >> For instance how do you "declare an object without a declared type"? > > > > malloc and other allocation functions return pointers to objects without > > a declared type. > > > > Thanks Florian, > > this discussion is very helpful. > > How about this for the documentation: > > @item typeless_storage > @cindex @code{typeless_storage} type attribute > In the context of section 6.5 paragraph 6 of the C11 standard, > an object of this type behaves as if it has no declared type. > In the context of section 6.5 paragraph 7 of the C11 standard, > an object or a pointer if this type behaves as if it were a > character type. > This is attribute is similar to the @code{may_alias} attribute, > except that it is not restricted to pointers. > > Example of use: > > @smallexample > typedef int __attribute__((__typeless_storage__)) int_a; > > int > main (void) > @{ > int_a a = 0x12345678; > short *b = (short *) &a; > > b[1] = 0; > > if (a == 0x12345678) > abort(); > > exit(0); > @} > @end smallexample Seriously, do not suggest such broken case. There's a union to do this example portably. Richard.