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 AD2B0385E02C for ; Tue, 24 May 2022 10:19:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AD2B0385E02C Received: from mail-yw1-f197.google.com (mail-yw1-f197.google.com [209.85.128.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-205-g-qXI3QaP7SIMAi0uwFCpA-1; Tue, 24 May 2022 06:19:00 -0400 X-MC-Unique: g-qXI3QaP7SIMAi0uwFCpA-1 Received: by mail-yw1-f197.google.com with SMTP id 00721157ae682-2fed8245a03so149898947b3.1 for ; Tue, 24 May 2022 03:19:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=e58rzcB/ZfHeVxIYDBvMyr8EBVhSZZDiGm+SzQncsmQ=; b=OALpMNONPHxdUsYt9vpM0BrAvbpxnxHM6R8gQUQNcNBAe5c8d5O4HRrqueJvsMTAC9 ZqMI5Zt5vvAQA5T1u7L0cEi3F+A5ft/G2tIlaOoBR9VAarH/wQvMIOLsttyE5nydiS3e 9DUu3uQwKAia9D6zlccoSy8VvPTeLk4MKVFa2GjBvBCRPJjIODna/3carvCfQxTzr5ZR Th28zdtjq6yus7fY6Hin2rEUPURjH6h02kyAohwkyCGUZoqg/W4bn7wGybZ2meexFGQM SsWyH9DKO9VhqtV7Q8uD64ZOQpqnBFzxZHPS70tC/IeOiGX/WD1lSOmbVz9br0izJD8i xu7Q== X-Gm-Message-State: AOAM531ZL4gN3eZgUTIJuFyFMixo03YlQnJNFhZMtjum3XTet/ye8+GI au4S11omECjnbTge8Q8zx7FvLhqNswKBxjMXD7C0QemrPXdrquU6MeU+mnLbpkchkYRG7gn0a1p SeCud9VFylN3+Sy2DvT7doxytJ36zxqo= X-Received: by 2002:a0d:d005:0:b0:2fe:de63:c298 with SMTP id s5-20020a0dd005000000b002fede63c298mr26967084ywd.473.1653387539733; Tue, 24 May 2022 03:18:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdp14ApBT98CT8CinYVKYuqRQXIm8NWr4fpHXge68X3JdopSWpErzYzj8c+T+WL6dVvWRRPH8atDdALugzI54= X-Received: by 2002:a0d:d005:0:b0:2fe:de63:c298 with SMTP id s5-20020a0dd005000000b002fede63c298mr26967069ywd.473.1653387539530; Tue, 24 May 2022 03:18:59 -0700 (PDT) MIME-Version: 1.0 References: <2fe3937d-1b9a-a547-bb41-225d3d5426a2@gmail.com> In-Reply-To: From: Jonathan Wakely Date: Tue, 24 May 2022 11:18:47 +0100 Message-ID: Subject: Re: [PATCH][_Hashtable] Fix insertion of range of type convertible to value_type PR 56112 To: =?UTF-8?Q?Fran=C3=A7ois_Dumont?= Cc: "libstdc++@gcc.gnu.org" , gcc-patches X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Tue, 24 May 2022 10:19:03 -0000 On Thu, 5 May 2022 at 18:38, Fran=C3=A7ois Dumont via Libstdc++ wrote: > > Hi > > Renewing my patch to fix PR 56112 but for the insert methods, I totally > change it, now works also with move-only key types. > > I let you Jonathan find a better name than _ValueTypeEnforcer as usual :-= ) > > libstdc++: [_Hashtable] Insert range of types convertible to value_type > PR 56112 > > Fix insertion of range of types convertible to value_type. Fix also when > this value_type > has a move-only key_type which also allow converted values to be moved. > > libstdc++-v3/ChangeLog: > > PR libstdc++/56112 > * include/bits/hashtable_policy.h (_ValueTypeEnforcer): New. > * include/bits/hashtable.h > (_Hashtable<>::_M_insert_unique_aux): New. > (_Hashtable<>::_M_insert(_Arg&&, const _NodeGenerator&, > true_type)): Use latters. > (_Hashtable<>::_M_insert(_Arg&&, const _NodeGenerator&, > false_type)): Likewise. > (_Hashtable(_InputIterator, _InputIterator, size_type, const > _Hash&, const _Equal&, > const allocator_type&, true_type)): Use this.insert range. > (_Hashtable(_InputIterator, _InputIterator, size_type, const > _Hash&, const _Equal&, > const allocator_type&, false_type)): Use _M_insert. > * testsuite/23_containers/unordered_map/cons/56112.cc: Check > how many times conversion > is done. > (test02): New test case. > * testsuite/23_containers/unordered_set/cons/56112.cc: New test. > > Tested under Linux x86_64. > > Ok to commit ? No, sorry. The new test02 function in 23_containers/unordered_map/cons/56112.cc doesn't compile with libc++ or MSVC either, are you sure that test is valid? I don't think it is, because S2 is not convertible to pair. None of the pair constructors are viable, because the move constructor would require two user-defined conversions (from S2 to pair and then from pair to pair). A conversion sequence cannot have more than one user-defined conversion using a constructor or converion operator. So if your patch makes that compile, it's a bug in the new code. I haven't analyzed that code to see where the problem is, I'm just looking at the test results and the changes in behaviour. The new 23_containers/unordered_set/cons/56112.cc test fails for GCC 11 but passes for GCC 12, even without your patch. Is it actually testing some other change, not this patch, and not the 2013 fix for PR 56112?