| Message ID | 20250917141825.585806-1-ppalka@redhat.com |
|---|---|
| State | New |
| Headers |
Return-Path: <gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 296F5385700E for <patchwork@sourceware.org>; Wed, 17 Sep 2025 14:20:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 296F5385700E Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=cv336G7c X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id F368A3858419 for <gcc-patches@gcc.gnu.org>; Wed, 17 Sep 2025 14:18:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F368A3858419 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org F368A3858419 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1758118712; cv=none; b=naSgtqvh94qid42HmKSN45Y9rTfwk1pwoBxL6Hzaj7H0U1L7sUyiHTSnnfSWFXLkjPrXVAs6M3va6Ro2VDqfzEVB3wPpUWNdIuzSmCrlqe4UH7uYvhtbVnYCHo9Q5enODeAZ12uauTxm9rqJrFKRGstGutifFBHyksBuxtecQUI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1758118712; c=relaxed/simple; bh=ZumCythSK2vqBIKe8GP4qaiGUBrCMTpT+oqOk8DrE/Q=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=q6Ec1K55MxEhQOrUabgaB00tyUDhoXfU2IKj46Nd3cBilXcif80Dfx87/WlKOMIhE/m22JkwHMcXnuaRII/Ixsr8FuMCgsGGJz7st+DNLv5SvFSG8tzHsaZ7SFb+EprBbxiLWjcJBUPhRbh0xGw29USGv2ffGMdomnNGe98CTcE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F368A3858419 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758118710; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=IzKjmtGzT5ckc6kB9CTd3w8XwVjrtnkTskqir0SEg68=; b=cv336G7cGjQTM7Eoer2575dm52agVkNKXDFW+z+RTef4RR9mbNd7M0s8M2/n44gSSLQSb0 BZ9l4OZywuzVacGeyu9jVbBDvmRciZYZ28im5ZOaJudSt8xie8zC2E3GeL5E54Y7MZgdu1 fALcEhncKYODvGKOtx5zfqfJh/9Z02M= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-561-25A83_rdPbGSa2qdFLu2Ug-1; Wed, 17 Sep 2025 10:18:29 -0400 X-MC-Unique: 25A83_rdPbGSa2qdFLu2Ug-1 X-Mimecast-MFC-AGG-ID: 25A83_rdPbGSa2qdFLu2Ug_1758118709 Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-4b79d7413eeso6643521cf.2 for <gcc-patches@gcc.gnu.org>; Wed, 17 Sep 2025 07:18:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758118708; x=1758723508; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=IzKjmtGzT5ckc6kB9CTd3w8XwVjrtnkTskqir0SEg68=; b=tS4OKqCIVHdfC4jJTUhKI3eOoBD4Emglf4Ecvu3omlEw3A9PzFn7GAaac+5PScay1C Hu0iTYHfbsSZuS7nXgnJgGmiDZhUIWeuyiIogxw7GsPltQE7HUNE+lx5bdMv1OEFLYsb YxkX1Xk+A7Y2JD1Ac0bdxTFyQ03O2UW6pZt7hfaoeYK6tujZLsavFJaworgQqq+8VMLF oqFUcTgCbppiyqOJrxO3trGB6C3UKNV452lEaCBShLtno3a9/o4F8DPbHwB3eKLrWqvZ E87QQxnmmWJNnCKEd/ASssG5iqWU1qiowmV4MuqxDy/v4qL0avLK+LJHd3K6OHnVqZTr 8XEg== X-Gm-Message-State: AOJu0YzXcVoHeBtG/Kwjua8Ac/datgqX4pauo7mp3t9g8e6m403+BnTw FgOlJN0MAWcUeN4wrCPWXsxnByU9S4lJ+Sdn78OB3Mq/QEdKfBRf5S17De5WtBnx9I++xKINS7j gp71hXrLmnCkVCzU1E7l4XuzRL000e0lP6d2Dpkys5tQEAV6eH0CuTdLwajsyvSjQKqZ/mqVQsH zxeCqSovBd+JJov8o4cE+Kv2UESk+PcAzHO5hIkGii X-Gm-Gg: ASbGncsW/JEP+hmmW1JSq7YSO4kGwLt/0J86d5vPhAWQPSUJaaouibv6Nqb0yPMkTcU iGttD4Y30WV55BIFzkY0AIoZd9j7Vb60a4noRtG6PLfJqJVwNYk6jpCTCYtCpr82DyXlUFUX05e Wb//4yRAVa0KQmQ2yz/Cu1kU86/+f6roJdLg2+frEnK4lqB9sZeCkDqMKvEkW88cZ8Me1Xx1/Mz r0BGqJekMNrLA3haRjMKx04sB+fh5Krxle55v0WQeaYlzknjyLGsKEyGc70RovFqPYEzsiuV3Zb yW+cQxRUm9LYvJ3MHugzrpMZWo8wVA== X-Received: by 2002:a05:622a:1904:b0:4b5:dfdc:1f0c with SMTP id d75a77b69052e-4ba6ae973b8mr18157341cf.12.1758118708311; Wed, 17 Sep 2025 07:18:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGQXgWCzSIH0Wfa6oiytgzRaBuOhHMJq/8fr/1LHL78ZDg2qM2V0PheBITbek46I/HsQZD+ww== X-Received: by 2002:a05:622a:1904:b0:4b5:dfdc:1f0c with SMTP id d75a77b69052e-4ba6ae973b8mr18156871cf.12.1758118707648; Wed, 17 Sep 2025 07:18:27 -0700 (PDT) Received: from idea ([2600:4040:aa68:6000:9e8e:99ff:fed1:71f]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4ba4dc077d6sm10880901cf.53.2025.09.17.07.18.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Sep 2025 07:18:27 -0700 (PDT) From: Patrick Palka <ppalka@redhat.com> To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Patrick Palka <ppalka@redhat.com> Subject: [PATCH] libstdc++/ranges: Fix more wrong value type init from reference type [PR111861] Date: Wed, 17 Sep 2025 10:18:25 -0400 Message-ID: <20250917141825.585806-1-ppalka@redhat.com> X-Mailer: git-send-email 2.51.0.268.ga483264b01 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: zKEKGuZv7cWC0GhjofShr-_x-1voPcW57OgYmawHQTY_1758118709 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-14.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_HOSTKARMA_W, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS, SPF_NONE, TXREP 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org |
| Series |
libstdc++/ranges: Fix more wrong value type init from reference type [PR111861]
|
|
Commit Message
Patrick Palka
Sept. 17, 2025, 2:18 p.m. UTC
Tested on x86_64-pc-linux-gnu, does this look OK for trunk/15/14? -- >8 -- As in r16-3912-g412a1f78b53709, this fixes some other spots where we wrongly use a deduced type and non-direct-initialization when intending to initialize a value type from an iterator's reference type. PR libstdc++/111861 libstdc++-v3/ChangeLog: * include/bits/ranges_algo.h (ranges::unique_copy): When initializing a value type object from *iter, use direct-initialization and don't use a deduced type. (ranges::push_heap): Use direct-initialization when initializing a value type object from ranges::iter_move. (ranges::max): As in ranges::unique_copy. * include/bits/ranges_util.h (ranges::min): Likewise. --- libstdc++-v3/include/bits/ranges_algo.h | 8 ++++---- libstdc++-v3/include/bits/ranges_util.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-)
Comments
On Wed, 17 Sept 2025 at 15:19, Patrick Palka <ppalka@redhat.com> wrote: > > Tested on x86_64-pc-linux-gnu, does this look OK for trunk/15/14? > > -- >8 -- > > As in r16-3912-g412a1f78b53709, this fixes some other spots where we > wrongly use a deduced type and non-direct-initialization when intending > to initialize a value type from an iterator's reference type. > > PR libstdc++/111861 > > libstdc++-v3/ChangeLog: > > * include/bits/ranges_algo.h (ranges::unique_copy): When > initializing a value type object from *iter, use > direct-initialization and don't use a deduced type. > (ranges::push_heap): Use direct-initialization when initializing > a value type object from ranges::iter_move. > (ranges::max): As in ranges::unique_copy. > * include/bits/ranges_util.h (ranges::min): Likewise. > --- > libstdc++-v3/include/bits/ranges_algo.h | 8 ++++---- > libstdc++-v3/include/bits/ranges_util.h | 2 +- > 2 files changed, 5 insertions(+), 5 deletions(-) > > diff --git a/libstdc++-v3/include/bits/ranges_algo.h b/libstdc++-v3/include/bits/ranges_algo.h > index 4025bba9f204..eebad9e1621c 100644 > --- a/libstdc++-v3/include/bits/ranges_algo.h > +++ b/libstdc++-v3/include/bits/ranges_algo.h > @@ -1529,7 +1529,7 @@ namespace ranges > } > else // indirectly_copyable_storable<_Iter, _Out> > { > - auto __value = *__first; > + iter_value_t<_Iter> __value(*__first); > *__result = __value; > while (++__first != __last) > { > @@ -2075,9 +2075,9 @@ namespace ranges > else > { > auto __comp_proj = __detail::__make_comp_proj(__comp, __proj); > + iter_value_t<_Iter> __value(ranges::iter_move(ranges::prev(__last))); > __detail::__push_heap(__first, (__last - __first) - 1, > - 0, ranges::iter_move(ranges::prev(__last)), > - __comp_proj); > + 0, __value, __comp_proj); Should this be std::move(__value)? I find it quite painful that the standard allows iterators to return a proxy that doesn't implicitly convert to the value type. Or that ranges::iter_move doesn't do the conversion and guarantee to return value_type or a real reference to value_type, instead of returning the proxy reference. It makes it quite difficult to write correct code. > return __last; > } > } > @@ -4219,7 +4219,7 @@ namespace ranges > auto __first = ranges::begin(__r); > auto __last = ranges::end(__r); > __glibcxx_assert(__first != __last); > - auto __result = *__first; > + range_value_t<_Range> __result(*__first); > while (++__first != __last) > { > auto&& __tmp = *__first; > diff --git a/libstdc++-v3/include/bits/ranges_util.h b/libstdc++-v3/include/bits/ranges_util.h > index 84de258908ea..2aa8938edf25 100644 > --- a/libstdc++-v3/include/bits/ranges_util.h > +++ b/libstdc++-v3/include/bits/ranges_util.h > @@ -761,7 +761,7 @@ namespace ranges > auto __first = ranges::begin(__r); > auto __last = ranges::end(__r); > __glibcxx_assert(__first != __last); > - auto __result = *__first; > + range_value_t<_Range> __result(*__first); > while (++__first != __last) > { > auto&& __tmp = *__first; > -- > 2.51.0.268.ga483264b01 >
On Wed, 17 Sep 2025, Jonathan Wakely wrote: > On Wed, 17 Sept 2025 at 15:19, Patrick Palka <ppalka@redhat.com> wrote: > > > > Tested on x86_64-pc-linux-gnu, does this look OK for trunk/15/14? > > > > -- >8 -- > > > > As in r16-3912-g412a1f78b53709, this fixes some other spots where we > > wrongly use a deduced type and non-direct-initialization when intending > > to initialize a value type from an iterator's reference type. > > > > PR libstdc++/111861 > > > > libstdc++-v3/ChangeLog: > > > > * include/bits/ranges_algo.h (ranges::unique_copy): When > > initializing a value type object from *iter, use > > direct-initialization and don't use a deduced type. > > (ranges::push_heap): Use direct-initialization when initializing > > a value type object from ranges::iter_move. > > (ranges::max): As in ranges::unique_copy. > > * include/bits/ranges_util.h (ranges::min): Likewise. > > --- > > libstdc++-v3/include/bits/ranges_algo.h | 8 ++++---- > > libstdc++-v3/include/bits/ranges_util.h | 2 +- > > 2 files changed, 5 insertions(+), 5 deletions(-) > > > > diff --git a/libstdc++-v3/include/bits/ranges_algo.h b/libstdc++-v3/include/bits/ranges_algo.h > > index 4025bba9f204..eebad9e1621c 100644 > > --- a/libstdc++-v3/include/bits/ranges_algo.h > > +++ b/libstdc++-v3/include/bits/ranges_algo.h > > @@ -1529,7 +1529,7 @@ namespace ranges > > } > > else // indirectly_copyable_storable<_Iter, _Out> > > { > > - auto __value = *__first; > > + iter_value_t<_Iter> __value(*__first); > > *__result = __value; > > while (++__first != __last) > > { > > @@ -2075,9 +2075,9 @@ namespace ranges > > else > > { > > auto __comp_proj = __detail::__make_comp_proj(__comp, __proj); > > + iter_value_t<_Iter> __value(ranges::iter_move(ranges::prev(__last))); > > __detail::__push_heap(__first, (__last - __first) - 1, > > - 0, ranges::iter_move(ranges::prev(__last)), > > - __comp_proj); > > + 0, __value, __comp_proj); > > Should this be std::move(__value)? Oops, fixed. > > I find it quite painful that the standard allows iterators to return a > proxy that doesn't implicitly convert to the value type. Or that > ranges::iter_move doesn't do the conversion and guarantee to return > value_type or a real reference to value_type, instead of returning the > proxy reference. It makes it quite difficult to write correct code. Yeah :/ How does the below look? This is probably not worth backporting actually. I doubt this causes problems in practice. -- >8 -- Subject: [PATCH] libstdc++/ranges: Fix more wrong value type init from reference type [PR111861] PR libstdc++/111861 libstdc++-v3/ChangeLog: * include/bits/ranges_algo.h (ranges::unique_copy): When initializing a value type object from *iter, use direct-initialization and don't use a deduced type. (ranges::push_heap): Use direct-initialization when initializing a value type object from ranges::iter_move. (ranges::max): As in ranges::unique_copy. * include/bits/ranges_util.h (ranges::min): Likewise. --- libstdc++-v3/include/bits/ranges_algo.h | 8 ++++---- libstdc++-v3/include/bits/ranges_util.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libstdc++-v3/include/bits/ranges_algo.h b/libstdc++-v3/include/bits/ranges_algo.h index 4025bba9f204..5c9fe627aee0 100644 --- a/libstdc++-v3/include/bits/ranges_algo.h +++ b/libstdc++-v3/include/bits/ranges_algo.h @@ -1529,7 +1529,7 @@ namespace ranges } else // indirectly_copyable_storable<_Iter, _Out> { - auto __value = *__first; + iter_value_t<_Iter> __value(*__first); *__result = __value; while (++__first != __last) { @@ -2075,9 +2075,9 @@ namespace ranges else { auto __comp_proj = __detail::__make_comp_proj(__comp, __proj); + iter_value_t<_Iter> __value(ranges::iter_move(ranges::prev(__last))); __detail::__push_heap(__first, (__last - __first) - 1, - 0, ranges::iter_move(ranges::prev(__last)), - __comp_proj); + 0, std::move(__value), __comp_proj); return __last; } } @@ -4219,7 +4219,7 @@ namespace ranges auto __first = ranges::begin(__r); auto __last = ranges::end(__r); __glibcxx_assert(__first != __last); - auto __result = *__first; + range_value_t<_Range> __result(*__first); while (++__first != __last) { auto&& __tmp = *__first; diff --git a/libstdc++-v3/include/bits/ranges_util.h b/libstdc++-v3/include/bits/ranges_util.h index 84de258908ea..2aa8938edf25 100644 --- a/libstdc++-v3/include/bits/ranges_util.h +++ b/libstdc++-v3/include/bits/ranges_util.h @@ -761,7 +761,7 @@ namespace ranges auto __first = ranges::begin(__r); auto __last = ranges::end(__r); __glibcxx_assert(__first != __last); - auto __result = *__first; + range_value_t<_Range> __result(*__first); while (++__first != __last) { auto&& __tmp = *__first;
On Wed, 17 Sept 2025 at 16:08, Patrick Palka <ppalka@redhat.com> wrote: > > On Wed, 17 Sep 2025, Jonathan Wakely wrote: > > > On Wed, 17 Sept 2025 at 15:19, Patrick Palka <ppalka@redhat.com> wrote: > > > > > > Tested on x86_64-pc-linux-gnu, does this look OK for trunk/15/14? > > > > > > -- >8 -- > > > > > > As in r16-3912-g412a1f78b53709, this fixes some other spots where we > > > wrongly use a deduced type and non-direct-initialization when intending > > > to initialize a value type from an iterator's reference type. > > > > > > PR libstdc++/111861 > > > > > > libstdc++-v3/ChangeLog: > > > > > > * include/bits/ranges_algo.h (ranges::unique_copy): When > > > initializing a value type object from *iter, use > > > direct-initialization and don't use a deduced type. > > > (ranges::push_heap): Use direct-initialization when initializing > > > a value type object from ranges::iter_move. > > > (ranges::max): As in ranges::unique_copy. > > > * include/bits/ranges_util.h (ranges::min): Likewise. > > > --- > > > libstdc++-v3/include/bits/ranges_algo.h | 8 ++++---- > > > libstdc++-v3/include/bits/ranges_util.h | 2 +- > > > 2 files changed, 5 insertions(+), 5 deletions(-) > > > > > > diff --git a/libstdc++-v3/include/bits/ranges_algo.h b/libstdc++-v3/include/bits/ranges_algo.h > > > index 4025bba9f204..eebad9e1621c 100644 > > > --- a/libstdc++-v3/include/bits/ranges_algo.h > > > +++ b/libstdc++-v3/include/bits/ranges_algo.h > > > @@ -1529,7 +1529,7 @@ namespace ranges > > > } > > > else // indirectly_copyable_storable<_Iter, _Out> > > > { > > > - auto __value = *__first; > > > + iter_value_t<_Iter> __value(*__first); > > > *__result = __value; > > > while (++__first != __last) > > > { > > > @@ -2075,9 +2075,9 @@ namespace ranges > > > else > > > { > > > auto __comp_proj = __detail::__make_comp_proj(__comp, __proj); > > > + iter_value_t<_Iter> __value(ranges::iter_move(ranges::prev(__last))); > > > __detail::__push_heap(__first, (__last - __first) - 1, > > > - 0, ranges::iter_move(ranges::prev(__last)), > > > - __comp_proj); > > > + 0, __value, __comp_proj); > > > > Should this be std::move(__value)? > > Oops, fixed. > > > > > I find it quite painful that the standard allows iterators to return a > > proxy that doesn't implicitly convert to the value type. Or that > > ranges::iter_move doesn't do the conversion and guarantee to return > > value_type or a real reference to value_type, instead of returning the > > proxy reference. It makes it quite difficult to write correct code. > > Yeah :/ > > How does the below look? This is probably not worth backporting > actually. I doubt this causes problems in practice. OK for trunk, and I agree that it's unlikely to matter to anybody, so not important to backport. > > -- >8 -- > > Subject: [PATCH] libstdc++/ranges: Fix more wrong value type init from > reference type [PR111861] > > PR libstdc++/111861 > > libstdc++-v3/ChangeLog: > > * include/bits/ranges_algo.h (ranges::unique_copy): When > initializing a value type object from *iter, use > direct-initialization and don't use a deduced type. > (ranges::push_heap): Use direct-initialization when initializing > a value type object from ranges::iter_move. > (ranges::max): As in ranges::unique_copy. > * include/bits/ranges_util.h (ranges::min): Likewise. > --- > libstdc++-v3/include/bits/ranges_algo.h | 8 ++++---- > libstdc++-v3/include/bits/ranges_util.h | 2 +- > 2 files changed, 5 insertions(+), 5 deletions(-) > > diff --git a/libstdc++-v3/include/bits/ranges_algo.h b/libstdc++-v3/include/bits/ranges_algo.h > index 4025bba9f204..5c9fe627aee0 100644 > --- a/libstdc++-v3/include/bits/ranges_algo.h > +++ b/libstdc++-v3/include/bits/ranges_algo.h > @@ -1529,7 +1529,7 @@ namespace ranges > } > else // indirectly_copyable_storable<_Iter, _Out> > { > - auto __value = *__first; > + iter_value_t<_Iter> __value(*__first); > *__result = __value; > while (++__first != __last) > { > @@ -2075,9 +2075,9 @@ namespace ranges > else > { > auto __comp_proj = __detail::__make_comp_proj(__comp, __proj); > + iter_value_t<_Iter> __value(ranges::iter_move(ranges::prev(__last))); > __detail::__push_heap(__first, (__last - __first) - 1, > - 0, ranges::iter_move(ranges::prev(__last)), > - __comp_proj); > + 0, std::move(__value), __comp_proj); > return __last; > } > } > @@ -4219,7 +4219,7 @@ namespace ranges > auto __first = ranges::begin(__r); > auto __last = ranges::end(__r); > __glibcxx_assert(__first != __last); > - auto __result = *__first; > + range_value_t<_Range> __result(*__first); > while (++__first != __last) > { > auto&& __tmp = *__first; > diff --git a/libstdc++-v3/include/bits/ranges_util.h b/libstdc++-v3/include/bits/ranges_util.h > index 84de258908ea..2aa8938edf25 100644 > --- a/libstdc++-v3/include/bits/ranges_util.h > +++ b/libstdc++-v3/include/bits/ranges_util.h > @@ -761,7 +761,7 @@ namespace ranges > auto __first = ranges::begin(__r); > auto __last = ranges::end(__r); > __glibcxx_assert(__first != __last); > - auto __result = *__first; > + range_value_t<_Range> __result(*__first); > while (++__first != __last) > { > auto&& __tmp = *__first; > -- > 2.51.0.268.ga483264b01 >
diff --git a/libstdc++-v3/include/bits/ranges_algo.h b/libstdc++-v3/include/bits/ranges_algo.h index 4025bba9f204..eebad9e1621c 100644 --- a/libstdc++-v3/include/bits/ranges_algo.h +++ b/libstdc++-v3/include/bits/ranges_algo.h @@ -1529,7 +1529,7 @@ namespace ranges } else // indirectly_copyable_storable<_Iter, _Out> { - auto __value = *__first; + iter_value_t<_Iter> __value(*__first); *__result = __value; while (++__first != __last) { @@ -2075,9 +2075,9 @@ namespace ranges else { auto __comp_proj = __detail::__make_comp_proj(__comp, __proj); + iter_value_t<_Iter> __value(ranges::iter_move(ranges::prev(__last))); __detail::__push_heap(__first, (__last - __first) - 1, - 0, ranges::iter_move(ranges::prev(__last)), - __comp_proj); + 0, __value, __comp_proj); return __last; } } @@ -4219,7 +4219,7 @@ namespace ranges auto __first = ranges::begin(__r); auto __last = ranges::end(__r); __glibcxx_assert(__first != __last); - auto __result = *__first; + range_value_t<_Range> __result(*__first); while (++__first != __last) { auto&& __tmp = *__first; diff --git a/libstdc++-v3/include/bits/ranges_util.h b/libstdc++-v3/include/bits/ranges_util.h index 84de258908ea..2aa8938edf25 100644 --- a/libstdc++-v3/include/bits/ranges_util.h +++ b/libstdc++-v3/include/bits/ranges_util.h @@ -761,7 +761,7 @@ namespace ranges auto __first = ranges::begin(__r); auto __last = ranges::end(__r); __glibcxx_assert(__first != __last); - auto __result = *__first; + range_value_t<_Range> __result(*__first); while (++__first != __last) { auto&& __tmp = *__first;