From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id C95CC385085E for ; Thu, 9 Mar 2023 08:44:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C95CC385085E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678351497; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=60lfqF2tVwtaOl6ONSLoMM6m9IunUbqtI0AM8Nbck9w=; b=fFSnWWjrJHLQc/73y1/+/BoKM2CEie48mT/vfE2Saj051PcYAstCm+iu3S5MgH2BexWkuA YQv66tolLMXLWe4i1J+jYHrehBK4da0ARF4Xym3fEI+Vp1giuoey00+5RYfC2pFA6TCOwQ u/7OE1dAKLB6oqXxgxoSWm+Dj1MdseQ= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-457-WyKJ7WWjMXGtsjB1bTf1zg-1; Thu, 09 Mar 2023 03:44:54 -0500 X-MC-Unique: WyKJ7WWjMXGtsjB1bTf1zg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D7CB728237C4; Thu, 9 Mar 2023 08:44:53 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 760CD440DD; Thu, 9 Mar 2023 08:44:53 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 3298iotP695787 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 9 Mar 2023 09:44:51 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 3298ioNa695786; Thu, 9 Mar 2023 09:44:50 +0100 Date: Thu, 9 Mar 2023 09:44:49 +0100 From: Jakub Jelinek To: Richard Biener Cc: Marek Polacek , GCC Patches Subject: Re: [PATCH] ubsan: missed -fsanitize=bounds for compound ops [PR108060] Message-ID: Reply-To: Jakub Jelinek References: <20230308210930.128620-1-polacek@redhat.com> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,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 Thu, Mar 09, 2023 at 08:12:47AM +0000, Richard Biener wrote: > I think this is a reasonable way to address the regression, so OK. It is true that both C and C++ (including c++14_down and c++17 and later where the latter have different ordering rules) evaluate the lhs of MODIFY_EXPR after rhs, so conceptually this patch makes sense. But I wonder why we do in ubsan_maybe_instrument_array_ref: if (e != NULL_TREE) { tree t = copy_node (*expr_p); TREE_OPERAND (t, 1) = build2 (COMPOUND_EXPR, TREE_TYPE (op1), e, op1); *expr_p = t; } rather than modification of the ARRAY_REF's operand in place. If we did that, we wouldn't really care about the order, shared tree would be instrumented once, with SAVE_EXPR in there making sure we don't compute that multiple times. Is that because the 2 copies could have side-effects and we do want to evaluate those multiple times? Jakub