]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Fix typo in std::fill SFINAE constraint [PR93059]
authorJonathan Wakely <jwakely@redhat.com>
Tue, 25 Feb 2025 18:06:46 +0000 (18:06 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Tue, 25 Feb 2025 22:34:16 +0000 (22:34 +0000)
The r15-4321-gd8ef4471cb9c9f change incorrectly used __value as the
member of the __memcpyable_integer trait, but it should have been
__width. That meant this overload was not being used for _Tp != _Up.

Also return after doing the loop for the consteval case. The missing
return wasn't causing incorrect behaviour because the consteval loop
increments the iterator until it equals the end of the range, so the
memset isn't done.  But it's still better to return and not even try
to do the memset.

libstdc++-v3/ChangeLog:

PR libstdc++/93059
* include/bits/stl_algobase.h (__fill_a1): Fix typo in SFINAE
constraint.

libstdc++-v3/include/bits/stl_algobase.h

index be311b91f53a032a0fdda69486598c2775bf22d2..fc7cc89736a86ad4a6d85cb43a6521a00b7fc4be 100644 (file)
@@ -943,7 +943,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
     inline typename
     __gnu_cxx::__enable_if<__is_byte<_Up>::__value
                             && (__are_same<_Up, _Tp>::__value // for std::byte
-                                  || __memcpyable_integer<_Tp>::__value),
+                                  || __memcpyable_integer<_Tp>::__width),
                           void>::__type
     __fill_a1(_Up* __first, _Up* __last, const _Tp& __x)
     {
@@ -955,6 +955,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
        {
          for (; __first != __last; ++__first)
            *__first = __val;
+         return;
        }
 #endif
       if (const size_t __len = __last - __first)