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.133.124]) by sourceware.org (Postfix) with ESMTPS id 6CAC5385DC31 for ; Tue, 24 May 2022 10:32:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6CAC5385DC31 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-460-ZWOm790gP6qwm4ylga3A-Q-1; Tue, 24 May 2022 06:32:03 -0400 X-MC-Unique: ZWOm790gP6qwm4ylga3A-Q-1 Received: by mail-yw1-f197.google.com with SMTP id 00721157ae682-2f7dbceab08so148376877b3.10 for ; Tue, 24 May 2022 03:32:03 -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=EdahNPyndwmcLnuvERKi9efW9hZb7T+xiP4KYM5+tUI=; b=1Ku5d1qJ/GraFXZdcvR6N19rBzDJ+gXEheAvkW0wi4nFn2xCWWry3Q90gGrWh9ih89 fVl/LmCY0Gbnq/Lt5Gbz8riBB1wa6HBoM4q9Frjn9JBHH6IA3dlSQGEx7D8TG3TzMOSt okTk7Kn+Ob4u8mbsghcB576V8qhhSKgUNW4KEPP+TU7wGgaV/09B1bxLzdasA1TzllZf 5EfalWHV79dZvmFMDPzesDHum3tQD55+tkJbN4XgIsMbeRxCUlXfoUM/wQQ8+SlRAEhp yoqAh730wNjdIqQIDIB1SaN9Y27pp0MCe6MtrWSGhu9Qdk0CHLWRxtv+hV3/DU51ViEL ODdQ== X-Gm-Message-State: AOAM530lQd2RgIs4dLJQT9M/3czG6V00bLL5e7hNSCMUtXImsK+uj0sB ric8uS9DEOMSHM6dJvjPfouEfyM007sTOJNi9qZAb9nmG2GeF8Oj73/3wMbuNw/Tc7Vi+qXpOS0 HvrHJZ/eROXv1JOeCfeqoash3j6dV9+o= X-Received: by 2002:a0d:d005:0:b0:2fe:de63:c298 with SMTP id s5-20020a0dd005000000b002fede63c298mr27014446ywd.473.1653388322727; Tue, 24 May 2022 03:32:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCds5/hvyLhQXigA2ESwN3vCqMotyZp3YlCD7VPzAiNuaI1FB5/jYIt/6qUOtQ3eQRIkN8TPZcZ1c3/ElZ+rE= X-Received: by 2002:a0d:d005:0:b0:2fe:de63:c298 with SMTP id s5-20020a0dd005000000b002fede63c298mr27014435ywd.473.1653388322555; Tue, 24 May 2022 03:32:02 -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:31:51 +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=-6.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_NUMSUBJECT, KAM_SHORT, 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:32:08 -0000 On Tue, 24 May 2022 at 11:22, Jonathan Wakely wrote: > > On Tue, 24 May 2022 at 11:18, Jonathan Wakely wrote: > > > > 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 total= ly > > > change it, now works also with move-only key types. > > > > > > I let you Jonathan find a better name than _ValueTypeEnforcer as usua= l :-) > > > > > > libstdc++: [_Hashtable] Insert range of types convertible to value_ty= pe > > > PR 56112 > > > > > > Fix insertion of range of types convertible to value_type. Fix also w= hen > > > this value_type > > > has a move-only key_type which also allow converted values to be move= d. > > > > > > 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 t= est. > > > > > > 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. > > I meant to include this link showing that libc++ and MSVC reject > test02() as well: > > https://godbolt.org/z/j7E9f6bd4 I've created https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105717 for the insertion bug, rather than reopening PR 56112.