public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/100287] New: Using iterator after std::move in ranges::partition
@ 2021-04-27 10:18 hewillk at gmail dot com
2021-04-27 13:41 ` [Bug libstdc++/100287] " ppalka at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: hewillk at gmail dot com @ 2021-04-27 10:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100287
Bug ID: 100287
Summary: Using iterator after std::move in ranges::partition
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: hewillk at gmail dot com
Target Milestone: ---
Hi, in ranges::partition in ranges_algo.h#L2540:
if (__first == __last)
return {std::move(__first), std::move(__first)};
while (std::__invoke(__pred, std::__invoke(__proj, *__first)))
if (++__first == __last)
return {std::move(__first), std::move(__first)};
The above two return statements std::move on __first twice. If the previous one
changes the original state of the __first, it may cause a problem.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libstdc++/100287] Using iterator after std::move in ranges::partition
2021-04-27 10:18 [Bug libstdc++/100287] New: Using iterator after std::move in ranges::partition hewillk at gmail dot com
@ 2021-04-27 13:41 ` ppalka at gcc dot gnu.org
2021-04-28 3:23 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-04-27 13:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100287
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
CC| |ppalka at gcc dot gnu.org
Last reconfirmed| |2021-04-27
Status|UNCONFIRMED |ASSIGNED
Ever confirmed|0 |1
--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Confirmed.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libstdc++/100287] Using iterator after std::move in ranges::partition
2021-04-27 10:18 [Bug libstdc++/100287] New: Using iterator after std::move in ranges::partition hewillk at gmail dot com
2021-04-27 13:41 ` [Bug libstdc++/100287] " ppalka at gcc dot gnu.org
@ 2021-04-28 3:23 ` cvs-commit at gcc dot gnu.org
2021-10-13 13:52 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-28 3:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100287
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:d91e7eab3a2c3957c2220ad71e62d9fc78cccb9b
commit r12-178-gd91e7eab3a2c3957c2220ad71e62d9fc78cccb9b
Author: Patrick Palka <ppalka@redhat.com>
Date: Tue Apr 27 23:21:19 2021 -0400
libstdc++: Fix various bugs in ranges_algo.h [PR100187, ...]
This fixes some bugs with our ranges algorithms in uncommon situations,
such as when the return type of a predicate is a non-copyable class type
that's implicitly convertible to bool (PR100187), when a comparison
predicate isn't invocable as an rvalue (PR100237), and when the return
type of a projection function is non-copyable (PR100249).
This also fixes PR100287, which reports that we're moving __first twice
when constructing with it an empty subrange in ranges::partition.
libstdc++-v3/ChangeLog:
PR libstdc++/100187
PR libstdc++/100237
PR libstdc++/100249
PR libstdc++/100287
* include/bits/ranges_algo.h (__search_n_fn::operator()): Give
the __value_comp lambda an explicit bool return type.
(__is_permutation_fn::operator()): Give the __proj_scan local
variable auto&& return type. Give the __comp_scan lambda an
explicit bool return type.
(__remove_fn::operator()): Give the __pred lambda an explicit
bool return type.
(__partition_fn::operator()): Don't std::move __first twice
when returning an empty subrange.
(__min_fn::operator()): Don't std::move __comp.
(__max_fn::operator()): Likewise.
(__minmax_fn::operator()): Likewise.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libstdc++/100287] Using iterator after std::move in ranges::partition
2021-04-27 10:18 [Bug libstdc++/100287] New: Using iterator after std::move in ranges::partition hewillk at gmail dot com
2021-04-27 13:41 ` [Bug libstdc++/100287] " ppalka at gcc dot gnu.org
2021-04-28 3:23 ` cvs-commit at gcc dot gnu.org
@ 2021-10-13 13:52 ` cvs-commit at gcc dot gnu.org
2021-10-13 13:56 ` cvs-commit at gcc dot gnu.org
2021-10-13 13:59 ` ppalka at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-10-13 13:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100287
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Patrick Palka
<ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:cb261f0e8fc08fb49f74002582ad5713cda684f7
commit r11-9145-gcb261f0e8fc08fb49f74002582ad5713cda684f7
Author: Patrick Palka <ppalka@redhat.com>
Date: Tue Apr 27 23:21:19 2021 -0400
libstdc++: Fix various bugs in ranges_algo.h [PR100187, ...]
This fixes some bugs with our ranges algorithms in uncommon situations,
such as when the return type of a predicate is a non-copyable class type
that's implicitly convertible to bool (PR100187), when a comparison
predicate isn't invocable as an rvalue (PR100237), and when the return
type of a projection function is non-copyable (PR100249).
This also fixes PR100287, which reports that we're moving __first twice
when constructing with it an empty subrange in ranges::partition.
libstdc++-v3/ChangeLog:
PR libstdc++/100187
PR libstdc++/100237
PR libstdc++/100249
PR libstdc++/100287
* include/bits/ranges_algo.h (__search_n_fn::operator()): Give
the __value_comp lambda an explicit bool return type.
(__is_permutation_fn::operator()): Give the __proj_scan local
variable auto&& return type. Give the __comp_scan lambda an
explicit bool return type.
(__remove_fn::operator()): Give the __pred lambda an explicit
bool return type.
(__partition_fn::operator()): Don't std::move __first twice
when returning an empty subrange.
(__min_fn::operator()): Don't std::move __comp.
(__max_fn::operator()): Likewise.
(__minmax_fn::operator()): Likewise.
(cherry picked from commit d91e7eab3a2c3957c2220ad71e62d9fc78cccb9b)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libstdc++/100287] Using iterator after std::move in ranges::partition
2021-04-27 10:18 [Bug libstdc++/100287] New: Using iterator after std::move in ranges::partition hewillk at gmail dot com
` (2 preceding siblings ...)
2021-10-13 13:52 ` cvs-commit at gcc dot gnu.org
@ 2021-10-13 13:56 ` cvs-commit at gcc dot gnu.org
2021-10-13 13:59 ` ppalka at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-10-13 13:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100287
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Patrick Palka
<ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:139bafaaba0c775ca65712621bd60e079b488d73
commit r10-10210-g139bafaaba0c775ca65712621bd60e079b488d73
Author: Patrick Palka <ppalka@redhat.com>
Date: Tue Apr 27 23:21:19 2021 -0400
libstdc++: Fix various bugs in ranges_algo.h [PR100187, ...]
This fixes some bugs with our ranges algorithms in uncommon situations,
such as when the return type of a predicate is a non-copyable class type
that's implicitly convertible to bool (PR100187), when a comparison
predicate isn't invocable as an rvalue (PR100237), and when the return
type of a projection function is non-copyable (PR100249).
This also fixes PR100287, which reports that we're moving __first twice
when constructing with it an empty subrange in ranges::partition.
libstdc++-v3/ChangeLog:
PR libstdc++/100187
PR libstdc++/100237
PR libstdc++/100249
PR libstdc++/100287
* include/bits/ranges_algo.h (__search_n_fn::operator()): Give
the __value_comp lambda an explicit bool return type.
(__is_permutation_fn::operator()): Give the __proj_scan local
variable auto&& return type. Give the __comp_scan lambda an
explicit bool return type.
(__remove_fn::operator()): Give the __pred lambda an explicit
bool return type.
(__partition_fn::operator()): Don't std::move __first twice
when returning an empty subrange.
(__min_fn::operator()): Don't std::move __comp.
(__max_fn::operator()): Likewise.
(__minmax_fn::operator()): Likewise.
(cherry picked from commit d91e7eab3a2c3957c2220ad71e62d9fc78cccb9b)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libstdc++/100287] Using iterator after std::move in ranges::partition
2021-04-27 10:18 [Bug libstdc++/100287] New: Using iterator after std::move in ranges::partition hewillk at gmail dot com
` (3 preceding siblings ...)
2021-10-13 13:56 ` cvs-commit at gcc dot gnu.org
@ 2021-10-13 13:59 ` ppalka at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-10-13 13:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100287
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
Target Milestone|--- |10.4
--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for 10.4/11.3/12
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-10-13 13:59 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-27 10:18 [Bug libstdc++/100287] New: Using iterator after std::move in ranges::partition hewillk at gmail dot com
2021-04-27 13:41 ` [Bug libstdc++/100287] " ppalka at gcc dot gnu.org
2021-04-28 3:23 ` cvs-commit at gcc dot gnu.org
2021-10-13 13:52 ` cvs-commit at gcc dot gnu.org
2021-10-13 13:56 ` cvs-commit at gcc dot gnu.org
2021-10-13 13:59 ` ppalka at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).