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 AF539385E02D for ; Tue, 24 May 2022 10:19:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AF539385E02D Received: from mail-yb1-f199.google.com (mail-yb1-f199.google.com [209.85.219.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-3-3d00wtCCM-GKyOoUeBFVWg-1; Tue, 24 May 2022 06:19:00 -0400 X-MC-Unique: 3d00wtCCM-GKyOoUeBFVWg-1 Received: by mail-yb1-f199.google.com with SMTP id e11-20020a25d30b000000b0064f6bcc95e4so9240831ybf.8 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=ONJGeJCKc4cAYPAHK64HcJBHmf3ALQQfSlcYVnvuOYbEe1b8cptSa84HQcNFmfWyzc qOvwttFhL1o7LrxdumxYTUjW0lWRQ/DPxM9MOCVMoocWESUALgnHJkTuC4DThP5Vlqfp 8M3c0XF103knW5uMVgDPZRS7LXakJ6rAyQC4j13550Jx8Rm8omlIsMhSPVSviMD3Opsv +7gXiyicY8ZGWz9AwQR3Yl1TDpKJytrDZzly4jBS1XLwsgJSH6DYnGK3CaB/aeOKVFhe a9PwznSvIetAChvCZuYPiE47DEXkPKzSqRHtgfNF32a/uuhw3luqW4ZTEsNhV/I3EAEz muhQ== X-Gm-Message-State: AOAM530Es/arHN4EtoV76xf9xvHulnmRXJ7XKaqgQQCK/T7pVvICeWXw xEQ2i9KuNJcDEFvL+FHVtUyoRv9OBs/8IURzmt+y86LBTryhvAPj0517ow12MPpdkd+Y8f8aWun XNKzJMVDiFu9zdqnlf/Vltg27Jtr4todzYw== X-Received: by 2002:a0d:d005:0:b0:2fe:de63:c298 with SMTP id s5-20020a0dd005000000b002fede63c298mr26967085ywd.473.1653387539734; 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=-4.3 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=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.29 Precedence: list List-Id: Gcc-patches 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?