From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 77491 invoked by alias); 22 Mar 2019 10:20:17 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 77479 invoked by uid 89); 22 Mar 2019 10:20:16 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=HX-Languages-Length:873, H*f:sk:c0e73e5, H*i:sk:c0e73e5 X-HELO: mailrelay3-3.pub.mailoutpod1-cph3.one.com Received: from mailrelay3-3.pub.mailoutpod1-cph3.one.com (HELO mailrelay3-3.pub.mailoutpod1-cph3.one.com) (46.30.212.12) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 22 Mar 2019 10:20:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=carewolf.com; s=20140924; h=content-type:content-transfer-encoding:mime-version:references:in-reply-to: message-id:date:subject:cc:to:from:from; bh=eaoSCJzY64P+nOETlywTeAmDvbVTxe2WrVuqqRVrxUw=; b=XXLkIO5GiL3gBowgR9VyVUDMOgjouHz25JV/1gFvLYZsulgeio6a0FrheZoKg+SWwy9b1el23Wl3k O10OAWh7f6UVcwBs2de4SPXo3yEdlsRUn9N7TSaslHVG+mZ/OU3vMH6P5b23VksPAf39VU8nI01FC/ uA9VN3xIiareSyj0= X-HalOne-Cookie: 3f476b984b813fa6f388146d2c70c1ff96629a1a X-HalOne-ID: 1316febd-4c8c-11e9-9a3b-d0431ea8bb03 Received: from carewolf.com (unknown [62.220.2.194]) by mailrelay3.pub.mailoutpod1-cph3.one.com (Halon) with ESMTPSA id 1316febd-4c8c-11e9-9a3b-d0431ea8bb03; Fri, 22 Mar 2019 10:20:11 +0000 (UTC) From: Allan Sandfeld Jensen To: gcc@gcc.gnu.org Cc: Andrew Haley , Jakub Jelinek Subject: Re: GCC turns &~ into | due to undefined bit-shift without warning Date: Fri, 22 Mar 2019 10:20:00 -0000 Message-ID: <6941168.EvYhyI6sBW@twilight> In-Reply-To: References: <4af9e251-f4c3-a5a4-e33d-fb8750c87e36@redheads.de> <2662071.e9J7NaK4W3@twilight> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" X-IsSubscribed: yes X-SW-Source: 2019-03/txt/msg00162.txt.bz2 On Freitag, 22. M=E4rz 2019 11:02:39 CET Andrew Haley wrote: > 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. >=20 > Is this belief about undefined behaviour commonplace among C programmers? > There's nothing in the standard to justify it: any expression which conta= ins > UB is undefined. Yes, even GCC uses undefined behavior when it is considered defined for=20 specific architecture, whether it be the result of unaligned access, negati= ve=20 shifts, etc. There is a lot of the warnings that UBSAN warns about that you= =20 will find both in GCC itself, the Linux kernel and many other places. 'Allan