From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23779 invoked by alias); 22 Mar 2019 13:38:15 -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 23770 invoked by uid 89); 22 Mar 2019 13:38:14 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1049 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 22 Mar 2019 13:38:13 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 45FBA309EFBB; Fri, 22 Mar 2019 13:38:12 +0000 (UTC) Received: from zebedee.pink (unknown [10.33.36.158]) by smtp.corp.redhat.com (Postfix) with ESMTP id 92D9B604C7; Fri, 22 Mar 2019 13:38:11 +0000 (UTC) Subject: Re: GCC turns &~ into | due to undefined bit-shift without warning To: Allan Sandfeld Jensen , gcc@gcc.gnu.org Cc: Jakub Jelinek References: <4af9e251-f4c3-a5a4-e33d-fb8750c87e36@redheads.de> <2662071.e9J7NaK4W3@twilight> <6941168.EvYhyI6sBW@twilight> From: Andrew Haley Openpgp: preference=signencrypt Message-ID: Date: Fri, 22 Mar 2019 13:38:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: <6941168.EvYhyI6sBW@twilight> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2019-03/txt/msg00167.txt.bz2 On 3/22/19 10:20 AM, Allan Sandfeld Jensen wrote: > On Freitag, 22. März 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. >> >> 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. > > Yes, even GCC uses undefined behavior when it is considered defined for > specific architecture, If it's defined for a specific architecture it's not undefined. Any compiler is entitled to do anything with UB, and "anything" includes extending the language to make it well defined. -- Andrew Haley Java Platform Lead Engineer Red Hat UK Ltd. EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671