This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: GCC turns &~ into | due to undefined bit-shift without warning
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Andrew Pinski <pinskia at gmail dot com>
- Cc: Allan Sandfeld Jensen <linux at carewolf dot com>, GCC Mailing List <gcc at gcc dot gnu dot org>, Andrew Haley <aph at redhat dot com>, Jakub Jelinek <jakub at redhat dot com>
- Date: Fri, 22 Mar 2019 23:42:27 +0000
- Subject: Re: GCC turns &~ into | due to undefined bit-shift without warning
- References: <4af9e251-f4c3-a5a4-e33d-fb8750c87e36@redheads.de> <6941168.EvYhyI6sBW@twilight> <e2c37a42-5daa-1e6b-502e-767ffc14b332@redhat.com> <5234980.DvuYhMxLoT@twilight> <CA+=Sn1=9VDoft0K2Af-VMOQUmCtHAxGDqrSZ88WOPedyN7P8ug@mail.gmail.com>
On Fri, 22 Mar 2019, Andrew Pinski wrote:
> "The practice of reading from a different union member than the one
> most recently written to (called “type-punning”) is common. Even with
> -fstrict-aliasing, type-punning is allowed, provided the memory is
> accessed through the union type."
> Maybe it should be more explicit saying even though the C/C++
> Langauges make it undefined, GCC makes it defined.
Type-punning is defined in C99 TC3 and later (albeit only in a
non-normative footnote, but the intent is clear).
--
Joseph S. Myers
joseph@codesourcery.com