[gcc r16-1966] libstdc++: Fix regression in std::uninitialized_fill for C++98 [PR120931]
Jonathan Wakely
redi@gcc.gnu.org
Thu Jul 3 09:34:58 GMT 2025
https://gcc.gnu.org/g:bc3ec8684f7111a06fde433bbe57caa385b178af
commit r16-1966-gbc3ec8684f7111a06fde433bbe57caa385b178af
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Jul 2 21:54:06 2025 +0100
libstdc++: Fix regression in std::uninitialized_fill for C++98 [PR120931]
A typo in r15-4473-g3abe751ea86e34 made it ill-formed to use
std::uninitialized_fill with iterators that aren't pointers (or pointers
wrapped in our __normal_iterator) if the value type is a narrow
character type.
libstdc++-v3/ChangeLog:
PR libstdc++/120931
* include/bits/stl_uninitialized.h (__uninitialized_fill<true>):
Fix typo resulting in call to __do_uninit_copy instead of
__do_uninit_fill.
* testsuite/20_util/specialized_algorithms/uninitialized_fill/120931.cc:
New test.
Diff:
---
libstdc++-v3/include/bits/stl_uninitialized.h | 2 +-
.../specialized_algorithms/uninitialized_fill/120931.cc | 16 ++++++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/libstdc++-v3/include/bits/stl_uninitialized.h b/libstdc++-v3/include/bits/stl_uninitialized.h
index f4b26cc9812e..3a37ddc71ba1 100644
--- a/libstdc++-v3/include/bits/stl_uninitialized.h
+++ b/libstdc++-v3/include/bits/stl_uninitialized.h
@@ -377,7 +377,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
std::__niter_base(__last),
__x);
else
- std::__do_uninit_copy(__first, __last, __x);
+ std::__do_uninit_fill(__first, __last, __x);
}
// Overload for pointers.
diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill/120931.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill/120931.cc
new file mode 100644
index 000000000000..766fac0e527b
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill/120931.cc
@@ -0,0 +1,16 @@
+// { dg-options "-std=gnu++98" }
+// { dg-do compile { target c++98_only } }
+// std::deque<character types>::resize() method fails with -std=c++98
+
+#include <memory>
+#include <testsuite_iterators.h>
+
+void
+test_pr120931()
+{
+ using __gnu_test::test_container;
+ using __gnu_test::forward_iterator_wrapper;
+ unsigned char c[1];
+ test_container<unsigned char, forward_iterator_wrapper> f(c);
+ std::uninitialized_fill(f.begin(), f.end(), 0);
+}
More information about the Libstdc++-cvs
mailing list