[Bug libstdc++/126604] [16/17 Regression] std::inclusive_scan moves from the first element of the input range

"redi at gcc dot gnu.org via Gcc-bugs" <[email protected]> Mon, 03 Aug 2026 15:42:45 +0000
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D126604

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I think we still want to use std::move(init) when passing it along, but sho=
uld
do:

--- a/libstdc++-v3/include/std/numeric
+++ b/libstdc++-v3/include/std/numeric
@@ -583,7 +583,8 @@ namespace __detail
     {
       if (__first !=3D __last)
        {
-         auto __init =3D _GLIBCXX_ITER_MOVE(__first);
+         typename iterator_traits<_InputIterator>::value_type __init
+           =3D *__first;
          *__result++ =3D __init;
          ++__first;
          if (__first !=3D __last)=