From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 59570 invoked by alias); 7 Apr 2017 12:58:59 -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 59490 invoked by uid 89); 7 Apr 2017 12:58:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-7.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_1,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: EUR03-AM5-obe.outbound.protection.outlook.com Received: from mail-oln040092070096.outbound.protection.outlook.com (HELO EUR03-AM5-obe.outbound.protection.outlook.com) (40.92.70.96) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 07 Apr 2017 12:58:55 +0000 Received: from DB5EUR03FT034.eop-EUR03.prod.protection.outlook.com (10.152.20.51) by DB5EUR03HT212.eop-EUR03.prod.protection.outlook.com (10.152.21.49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.1019.14; Fri, 7 Apr 2017 12:58:53 +0000 Received: from AM4PR0701MB2162.eurprd07.prod.outlook.com (10.152.20.53) by DB5EUR03FT034.mail.protection.outlook.com (10.152.20.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1019.14 via Frontend Transport; Fri, 7 Apr 2017 12:58:53 +0000 Received: from AM4PR0701MB2162.eurprd07.prod.outlook.com ([fe80::a806:64f0:6377:f3ea]) by AM4PR0701MB2162.eurprd07.prod.outlook.com ([fe80::a806:64f0:6377:f3ea%19]) with mapi id 15.01.1019.021; Fri, 7 Apr 2017 12:58:53 +0000 From: Bernd Edlinger To: Richard Biener CC: Florian Weimer , Jakub Jelinek , Jonathan Wakely , GCC Patches , Jason Merrill , Jeff Law Subject: Re: [PATCH] Add a new type attribute always_alias (PR79671) Date: Fri, 07 Apr 2017 12:58:00 -0000 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> In-Reply-To: authentication-results: suse.de; dkim=none (message not signed) header.d=none;suse.de; dmarc=none action=none header.from=hotmail.de; x-incomingtopheadermarker: OriginalChecksum:1C80F421B17F5223CD8E0F7A3755470A66A405B489B44AA5BC27E4BE41FD873F;UpperCasedChecksum:E8949AB37AB747FA1060B9E3E036663741C7F6E7EF49F3980BA7FD4A9ACD7644;SizeAsReceived:9237;Count:40 x-ms-exchange-messagesentrepresentingtype: 1 x-microsoft-exchange-diagnostics: 1;DB5EUR03HT212;5:J5SwMscyTDKbVmhZGV0aBkUc/c0qZNrc8NeORuYqIxI4AI31cR7QO9DKhkVP1MQLyNzD8/PQcsth3Pxvi5IIorz9/JZpQinLpdtSutULK9DHi4cFnn2BJnIOi6zLgf516K3QyTGaJGBZC7nFoKWMITg+CFcSqMM+gp6GNJcIv1Q=;24:rI5OGj68qpa97dSg1PKXfPjKyNScBYU8Jyl9mqF1XXt7BGWGDw0REqBSIyUAyKWoCAK6IdASXjoMYgR3pXqORqvzrjQWPWz1Ohjf9mtkXOQ=;7:moxZC7x7HEu+z0T8BaAS2M76p6PL2NLY+8hAy0EsVdyfAzZsQCIDEW+jdd2pdCSgS6G6Trk5PABX3fKNNjtkVSq9PfgQB20yjbnzPa/xUAbiFeseVDFBFv/O8CJ1GoM1VlNzDKIFnugB9HuwoKt+uIiAIMpbx5/oakqgfMa4uuAkrZllDFmv2fC11SF1BY14ZVoeJQ3sZEo2cxe1ITvFav9xx4crN6xqMRC55l7N/yP/JSaW7kRuOsuawFAbSSqBaoktQBIRIjoCJcuK2x9hnufKrgNd0JKDAV0BE3Fr/cPquV50sj82HinzriqdbwUH x-incomingheadercount: 40 x-eopattributedmessage: 0 x-forefront-antispam-report: EFV:NLI;SFV:NSPM;SFS:(7070007)(98901004);DIR:OUT;SFP:1901;SCL:1;SRVR:DB5EUR03HT212;H:AM4PR0701MB2162.eurprd07.prod.outlook.com;FPR:;SPF:None;LANG:en; x-ms-office365-filtering-correlation-id: 2134c628-c3af-4535-0813-08d47db5d73e x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201702061074)(5061506573)(5061507331)(1603103135)(2017031320274)(2017031322274)(1603101448)(1601125374)(1701031045);SRVR:DB5EUR03HT212; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(444000031);SRVR:DB5EUR03HT212;BCL:0;PCL:0;RULEID:;SRVR:DB5EUR03HT212; x-forefront-prvs: 0270ED2845 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="Windows-1252" Content-ID: <5847C6D2DF27FC4280B99DAF8C4792C1@eurprd07.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Apr 2017 12:58:53.2492 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5EUR03HT212 X-SW-Source: 2017-04/txt/msg00366.txt.bz2 On 04/07/17 08:47, Richard Biener wrote: > 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 =3D 0x12345678; >> short *b =3D (short *) &a; >> >> b[1] =3D 0; >> >> if (a =3D=3D 0x12345678) >> abort(); >> >> exit(0); >> @} >> @end smallexample > > Seriously, do not suggest such broken case. There's a union to > do this example portably. > Well, it is just a mod of the other example above in the documentation of may_alias: typedef short __attribute__((__may_alias__)) short_a; int main (void) @{ int a =3D 0x12345678; short_a *b =3D (short_a *) &a; b[1] =3D 0; if (a =3D=3D 0x12345678) abort(); exit(0); @} @end smallexample I just moved the attribute from "b" to "a", and that is what the C++ people want to do as well, just they call it a "class int_a { std::byte x[4]; }". I personally like to have the symmetry between the two concepts here, because it helps to understand the differences. Bernd. > Richard. >