From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by sourceware.org (Postfix) with ESMTPS id 48C5A3858CDB for ; Mon, 18 Sep 2023 14:56:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 48C5A3858CDB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-5031426b626so1919548e87.3 for ; Mon, 18 Sep 2023 07:56:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695048960; x=1695653760; darn=gcc.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=KuOBt1BSH1n5MRF80T+4dNwzV/98OQWMZiUbZ0YxDfs=; b=A88Jczh6/IuSje7X5dVhoXZZTCZwK9hu24vG3LnyR+5W4ELILbgHFkZw3ffCPCgtt1 kr4Zy6YFthVPSBvCt4QAVeJmfjhuUxxnmuk7zmKYZEXRsgL6QejNjhC23f1tz60T4teC paznqTh1f4HB6IAl/wIcdbXLrlM0MRl4tFtgIQoMFbnT8gQWjfYTpG1vD3JIUuw+N1xY 0PhHTCUaVDoYIVbghvbZ/L0I6QGa/p17jwL1l+mGBA/LT2DTdstEX6xYZ2xJVK9cbRNH 4IPYO9dRymvsgnbp5udLbsL+eeDuf2M7y+bpf1hpZn+xhkqmQQ+YBtc4JI4S6lDInizI VrkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695048960; x=1695653760; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KuOBt1BSH1n5MRF80T+4dNwzV/98OQWMZiUbZ0YxDfs=; b=VylVCn7s7GgYUT5rE2XLVAqk4zS87UuQXw6vp3FhJDy/1yrjOMExnbrQIUnpHfDM8G mRMmbPxPlw2sjUJKQTmxqnuTDPj3U5cjaczY0KEoGISkn08ZM5gklCawgow2kG0oNlQ2 A4VUZW44htD72+0DYPvyBApV6t/mHqWdz4+zST+B6TLz2fVrjdMOR+UlR9Etvfb9CqAy aPrAwL5R/duD6E4g9pyUv1f3dVUQqTpmVe1Nck2308NiT1zj//pdZ8xPsk6s7XwSUXmc q8jF/C3XhayGoobdidrdqlgGuSC09cPni6tUEdm6xRw2MbWbgHoXRGA9zfQYv09MOQSB EWqg== X-Gm-Message-State: AOJu0YzZLHLAMAIk3ZabaM+ODkbDkAMYxqdm6698r7wQJScEXEhhDsgV BD0ZuervCl2llzuWhPGm4tiXtzkwRjCwjc2TqJMXw/te X-Google-Smtp-Source: AGHT+IEGs60kakh4oqR1RIhZuqAVwJL2HdzrHh3ehouj90ADkM0KFUnTojaji+vs2oR1G8duaDaykSuOgUANpUd6IbQ= X-Received: by 2002:a05:6512:12cd:b0:502:9bb6:3aba with SMTP id p13-20020a05651212cd00b005029bb63abamr8753175lfg.14.1695048959453; Mon, 18 Sep 2023 07:55:59 -0700 (PDT) MIME-Version: 1.0 References: <12c6db0e-10cf-eef6-6209-77da64738897@free.fr> In-Reply-To: From: Richard Biener Date: Mon, 18 Sep 2023 16:55:47 +0200 Message-ID: Subject: Re: Safe transposition of logical and operands To: "Floyd, Paul" Cc: "gcc@gcc.gnu.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, Sep 18, 2023 at 4:49=E2=80=AFPM Floyd, Paul via Gcc wrote: > > Hi Richard and Jonathan > > On 18/09/2023 10:00, Richard Biener wrote: > > On Mon, Sep 18, 2023 at 9:24=E2=80=AFAM Jonathan Wakely via Gcc wrote: > >> Yes, GCC assumes that the reference is bound to a valid object, becaus= e C++ > >> requires that to be true. Of course memcheck can't assume that, becaus= e one > >> of its main reasons to exist is to find undefined behaviour where that > >> isn't true! > > It's even worse than that. This transformation is being done in VEX > (which unfortunately > is also the bit I know the least). Not normally where we'd do > accessibility checks. > > >> I think what GCC is doing is a valid transformation, in the context of= a > >> valid C++ program. But I'm not sure that helps valgrind, which doesn't= have > >> the liberty of assuming a valid program. > > More specifically GCC thinks it's fine to speculate loads (given it can= prove > > doing so doesn't trap) > > I don't think that will be easy for us to prove. We just don't know > enough about stack variables. What you could do is report the access only on the point of use of the accessed value? (and disregard when the register holding the value is re-used) Richard. > A+ > > Paui