From patchwork Thu Feb 8 21:49:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1896775 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=AeAgQISS; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TW9fB1x1pz23hZ for ; Fri, 9 Feb 2024 08:50:58 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3311F385842C for ; Thu, 8 Feb 2024 21:50:56 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 6B7EE3858C78 for ; Thu, 8 Feb 2024 21:49:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6B7EE3858C78 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6B7EE3858C78 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707428984; cv=none; b=JPjAG+O3OAiF97O62h+Vp8L8Pv++UTijg+q2irLFXDlRpkF4J12beByR82/DJAoxU77BLNle/UtqU6Vfnskyo099WuIR8S0y2yHF6SK4udMVVNHbNr7EEn5k2izWpCx/WVunXBA7MRe03nb4JPY7Zu/YwK9BZEkJMCuFLCnQzJQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707428984; c=relaxed/simple; bh=dm5UfFIk9ZjUaOiiYHQYn6WM9kqA5UAv3ET+/VtoqfU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=G6JWkbvP49lOnAu62jz9Erqu4LO5cL86i0XvNBLFmEqjoqAfLGA1ntK8WEVwzIsn76x7SN1NXJlDrO2qgzSC8n7d6gC82nIEiDDnxOcbtfClhiHqRNz9xQ9KNV+1yzWyIQ+ooDf63GfUeBjwbKneCJMt0Mrtsj5X7wRj0/fDNOc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707428977; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZkMUlnZ/n/6SzjL3WdZefuPLFg29t4SswXPx6G9e8VE=; b=AeAgQISS7/ztgTOmMozogVX/89636SGEB+vDV9KprvN5ApeLyrTSjGeiLKbsr1U52fhRnP Li51/IiLTEeakTsz23foRZgDocSt9rzC0jSnVNfBby4Ux/q8NRMeQiwzutl90gfY6gSHln Fzqu2/8EV2X7RFAFgsCcSy4SphZZstM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-304-9kd-qiwDO76x8ZbxuXKrlw-1; Thu, 08 Feb 2024 16:49:34 -0500 X-MC-Unique: 9kd-qiwDO76x8ZbxuXKrlw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DD2FE83B8E5; Thu, 8 Feb 2024 21:49:33 +0000 (UTC) Received: from localhost (unknown [10.42.28.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 90FDEC1596E; Thu, 8 Feb 2024 21:49:33 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Add comment to gslice::operator=(const gslice&) [PR100147] Date: Thu, 8 Feb 2024 21:49:10 +0000 Message-ID: <20240208214932.2737795-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Tested aarch64-linux. Pushed to trunk. -- >8 -- There's no need to check for self-assignment here, it would just add extra code for an unlikely case. Add a comment saying so. libstdc++-v3/ChangeLog: PR libstdc++/100147 * include/bits/gslice.h (operator=): Add comment about lack of self-assignment check. --- libstdc++-v3/include/bits/gslice.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libstdc++-v3/include/bits/gslice.h b/libstdc++-v3/include/bits/gslice.h index 3d78da2bd75..d9a8b929a57 100644 --- a/libstdc++-v3/include/bits/gslice.h +++ b/libstdc++-v3/include/bits/gslice.h @@ -169,6 +169,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION inline gslice& gslice::operator=(const gslice& __g) { + // Safe for self-assignment. Checking for it would add overhead just to + // optimize a case that should never happen anyway. if (__g._M_index) __g._M_index->_M_increment_use(); if (_M_index && _M_index->_M_decrement_use() == 0)