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: Andrew Haley <aph at redhat dot com>
- To: Allan Sandfeld Jensen <linux at carewolf dot com>, gcc at gcc dot gnu dot org, Jakub Jelinek <jakub at redhat dot com>
- Date: Fri, 22 Mar 2019 10:02:39 +0000
- Subject: Re: GCC turns &~ into | due to undefined bit-shift without warning
- References: <4af9e251-f4c3-a5a4-e33d-fb8750c87e36@redheads.de> <20190311091449.GB7611@tucnak> <2662071.e9J7NaK4W3@twilight>
On 3/21/19 10:19 PM, Allan Sandfeld Jensen wrote:
> From having fixed UBSAN warnings, I have seen many cases where undefined
> behavior was performed, but where the code was aware of it and the final
> result of the expression was well defined nonetheless.
Is this belief about undefined behaviour commonplace among C programmers?
There's nothing in the standard to justify it: any expression which contains
UB is undefined.
--
Andrew Haley
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671