From patchwork Mon Aug 9 10:23:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Fran=C3=A7ois_Dumont?= X-Patchwork-Id: 1515006 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=QWPsip4c; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Gjsfz1JXQz9sWl for ; Mon, 9 Aug 2021 20:25:47 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E4C7A3892033 for ; Mon, 9 Aug 2021 10:25:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E4C7A3892033 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1628504744; bh=1P36bl/0VQODWSu1+jBhwYpIQURdQhcatmxiJ1QaQDM=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=QWPsip4cT8quToanKAviuS6SbSq7D5yQt89674ZnlBxBKXVqvU026OTFbNCQcL8i6 DuA+4DpLA9T4Hdkib9ufoUF3vTGKcogRlw0Oe8BHwZ1AAbD1n12lvestuihsH1BAcy n8GIn9ezQg8D+SE50U4ngw6aiCYsICNBjEsS4bdQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by sourceware.org (Postfix) with ESMTPS id 6BAF238930C9; Mon, 9 Aug 2021 10:23:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6BAF238930C9 Received: by mail-wm1-x32d.google.com with SMTP id f9-20020a05600c1549b029025b0f5d8c6cso14168593wmg.4; Mon, 09 Aug 2021 03:23:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-language; bh=1P36bl/0VQODWSu1+jBhwYpIQURdQhcatmxiJ1QaQDM=; b=IttVxqjlyL/f3s+4zlL1Noq9K7vSf+2oBVtkXGqt6t1PWx8OubrlMT+0h4ARoByMir rra0we3qmTt6WilVeCkln8OkF8dweHkZbKra+q19133rPCRszExgjJLSQalfoE5Zmr4k k85J5NAOeYVccVQaT6GZ+VwRMo5nvYsV97r0LDbtmq3auFv8pikB1Y/yECgXy8fk3Umm 42uaB5KIpWSMR6jfn/dL5kC9jS64mE/vDfccOCI8J2fJtKtLLggRZSN/5dtdxx8raUXa Ab+kHP2ykx55JZtoN1wRmMJtdhUzqiFTjcYt97UEd7dFZFPfpjBsaINjWLvfJcn0gu89 F7jQ== X-Gm-Message-State: AOAM530KDNDpRjKuWqg3ioiRCgRro7p+LkqonhGN9yYlJMk8u0kPQRq5 L1zyhfu5dPwr7p1AGLqSSgSMbq8Y+Fk= X-Google-Smtp-Source: ABdhPJyS9793K5zoSXecLCHCkCKhVXdXF34JNGf3qGGMLL2eahgTAOpa4Fv7ujFgwiu+KBfHdSAH5A== X-Received: by 2002:a05:600c:3798:: with SMTP id o24mr2089503wmr.18.1628504637378; Mon, 09 Aug 2021 03:23:57 -0700 (PDT) Received: from [192.168.42.233] (pop.92-184-100-27.mobile.abo.orange.fr. [92.184.100.27]) by smtp.googlemail.com with ESMTPSA id k186sm25075670wme.45.2021.08.09.03.23.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 09 Aug 2021 03:23:56 -0700 (PDT) To: "libstdc++@gcc.gnu.org" Subject: [PATCH] Avoid allocator operator== in _Safe_container Message-ID: <6edc763b-e463-a676-0232-7b2193fb403b@gmail.com> Date: Mon, 9 Aug 2021 12:23:55 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 Content-Language: fr X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Fran=C3=A7ois_Dumont_via_Gcc-patches?= From: =?utf-8?q?Fran=C3=A7ois_Dumont?= Reply-To: =?utf-8?q?Fran=C3=A7ois_Dumont?= Cc: gcc-patches Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Some newly introduced tests in 23_containers/unordered_map/cons/default.cc revealed that we are forcing the allocator type to have a operator==. It can be avoided by checking allocator_traits::is_always_equal.     libstdc++: [_GLIBCXX_DEBUG] Avoid allocator operator== when always equal     Use std::allocator_traits::is_always_equal to find out if we need to compare     allocator instances on safe container allocator aware move constructor.     libstdc++-v3/ChangeLog:             * include/debug/safe_container.h             (_Safe_container(_Safe_container&&, const _Alloc&, std::true_type)): New.             (_Safe_container(_Safe_container&&, const _Alloc&, std::false_type)): New.             (_Safe_container(_Safe_container&&, const _Alloc&)): Use latters. Tested under Linux x86 Debug mode. Ok to commit ? François diff --git a/libstdc++-v3/include/debug/safe_container.h b/libstdc++-v3/include/debug/safe_container.h index d9636c29e9b..b06c33dac7e 100644 --- a/libstdc++-v3/include/debug/safe_container.h +++ b/libstdc++-v3/include/debug/safe_container.h @@ -57,7 +57,12 @@ namespace __gnu_debug _Safe_container(const _Safe_container&) = default; _Safe_container(_Safe_container&&) = default; - _Safe_container(_Safe_container&& __x, const _Alloc& __a) + private: + _Safe_container(_Safe_container&& __x, const _Alloc& __a, std::true_type) + : _Safe_container() + { _Base::_M_swap(__x); } + + _Safe_container(_Safe_container&& __x, const _Alloc& __a, std::false_type) : _Safe_container() { if (__x._M_cont().get_allocator() == __a) @@ -65,6 +70,12 @@ namespace __gnu_debug else __x._M_invalidate_all(); } + + protected: + _Safe_container(_Safe_container&& __x, const _Alloc& __a) + : _Safe_container(std::move(__x), __a, + typename std::allocator_traits<_Alloc>::is_always_equal{}) + { } #endif public: