From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23639 invoked by alias); 20 Mar 2019 14:26:28 -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 23628 invoked by uid 89); 20 Mar 2019 14:26:28 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=2.9 required=5.0 tests=AWL,BAYES_50,FOREIGN_BODY1,KHOP_DYNAMIC,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=no version=3.3.1 spammy=8:re, 8:sc, telefon, brings X-HELO: mx07-00178001.pphosted.com Received: from mx08-00178001.pphosted.com (HELO mx07-00178001.pphosted.com) (91.207.212.93) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 20 Mar 2019 14:26:26 +0000 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x2KEMH1d032408 for ; Wed, 20 Mar 2019 15:26:24 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2r8rwk7tr9-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Wed, 20 Mar 2019 15:26:24 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 9A74A34 for ; Wed, 20 Mar 2019 14:26:23 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag5node1.st.com [10.75.127.13]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 607FC52BF for ; Wed, 20 Mar 2019 14:26:23 +0000 (GMT) Received: from [10.129.178.138] (10.75.127.49) by SFHDAG5NODE1.st.com (10.75.127.13) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Wed, 20 Mar 2019 15:26:22 +0100 Subject: Re: GCC turns &~ into | due to undefined bit-shift without warning To: References: <4af9e251-f4c3-a5a4-e33d-fb8750c87e36@redheads.de> <20190311091449.GB7611@tucnak> <9085342b-41a6-851c-28e3-08a40cc30103@redheads.de> <20190311111702.GD7611@tucnak> <99e48024-6331-2ba6-272c-51f8cf9e9780@redheads.de> From: Christophe Lyon Message-ID: <5add8d67-039c-76bc-9a02-b6e09e771b33@st.com> Date: Wed, 20 Mar 2019 14:26:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.3 MIME-Version: 1.0 In-Reply-To: <99e48024-6331-2ba6-272c-51f8cf9e9780@redheads.de> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2019-03/txt/msg00141.txt.bz2 On 20/03/2019 15:08, Moritz Strübe wrote: > Hey. > > Am 11.03.2019 um 12:17 schrieb Jakub Jelinek: > > On Mon, Mar 11, 2019 at 11:06:37AM +0000, Moritz Strübe wrote: > > > On 11.03.2019 at 10:14 Jakub Jelinek wrote: > > > You could build with -fsanitize=undefined, that would tell you at runtime you > have undefined behavior in your code (if the SingleDiff has bit ever 0x20 > set). > > > Yes, that helps. Unfortunately I'm on an embedded system, thus the code > size increase is just too big. > > > You can -fsanitize-undefined-trap-on-error, which doesn't increase size too > much, it is less user-friendly, but still should catch the UB. > > Wouldn't this fail to link? I thought the sanitizers need some runtime libraries which are only available under linux/macos/android. What do you mean by embedded? Isn't it arm-eabi? > > Ok, I played around a bit. Interestingly, if I set -fsanitize=udefined and -fsanitize-undefined-trap-on-error the compiler detects that it will always trap, and optimizes the code accordingly (the code after the trap is removed).* Which kind of brings me to David's argument: Shouldn't the compiler warn if there is undefined behavior it certainly knows of? > I do assume though that fsanitize just injects the test-code everywhere and relies on the compiler to remove it at unnecessary places. Would be nice, though. :) > Could you confirm in which version of the ST libraries you noticed this bug? I'm told it was fixed on 23-march-2018. Thanks, Christophe > Cheers > Morty > > *After fixing the code, it got too big to fit. > > > -- > Redheads Ltd. Softwaredienstleistungen > Schillerstr. 14 > 90409 Nürnberg > > Telefon: +49 (0)911 180778-50 > E-Mail: moritz.struebe@redheads.de | Web: www.redheads.de > > Geschäftsführer: Andreas Hanke > Sitz der Gesellschaft: Lauf > Amtsgericht Nürnberg HRB 22681 > Ust-ID: DE 249436843 >