[Bug libstdc++/100287] New: Using iterator after std::move in ranges::partition
hewillk at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Apr 27 10:18:17 GMT 2021
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.
More information about the Gcc-bugs
mailing list