From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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" Cc: gcc-patches From: =?UTF-8?Q?Fran=c3=a7ois_Dumont?= 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-Type: multipart/mixed; boundary="------------0A79FA131F6E32B0E4305651" 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: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2021 10:23:59 -0000 This is a multi-part message in MIME format. --------------0A79FA131F6E32B0E4305651 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit 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 --------------0A79FA131F6E32B0E4305651 Content-Type: text/x-patch; charset=UTF-8; name="safe_container.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="safe_container.patch" 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: --------------0A79FA131F6E32B0E4305651--