Running the testsuite with warnings enabled gives:
FAIL: 20_util/specialized_algorithms/uninitialized_copy/58982.cc -std=gnu++26
(test for excess errors)
Excess errors:
.../libstdc++-v3/include/bits/stl_uninitialized.h:293: warning: 'void*
__builtin_memcpy(void*, const void*, long unsigned int)' writing to an object
of type 'struct T' with no trivial copy-assignment; use copy-initialization
instead [-Wclass-memaccess]
This is because -Wclass-memaccess warns about using memcpy on types
which have a deleted assignment, even though those can be trivially
copyable and so using memcpy on them is technically valid. Where these
warnings occur in bits/stl_uninitialized.h we're only using memcpy after
checking for trivially copyable (and any other relevant conditions) so
we can be confident that we're using it safely. We also don't actually
care about assignment here because we're only constructing new objects,
not copying over existing ones (which is what std::copy does, but not
std::uninitialized_copy).
Uses of memcpy in the C++98 code don't need to have -Wclass-memaccess
suppressed, because there are no deleted functions in C++98 so there are
no types which are trivially copyable but trigger the warning.
libstdc++-v3/ChangeLog:
* include/bits/stl_uninitialized.h (uninitialized_copy)
(uninitialized_fill, uninitialized_fill_n): Use pragmas to
suppress -Wclass-memaccess warnings.
---
Tested powerpc64le-linux.
libstdc++-v3/include/bits/stl_uninitialized.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/libstdc++-v3/include/bits/stl_uninitialized.h
b/libstdc++-v3/include/bits/stl_uninitialized.h
index 0398b65fa140..70a564659814 100644
--- a/libstdc++-v3/include/bits/stl_uninitialized.h
+++ b/libstdc++-v3/include/bits/stl_uninitialized.h
@@ -236,6 +236,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wc++17-extensions"
+#pragma GCC diagnostic ignored "-Wclass-memaccess"
/**
* @brief Copies the range [first,last) into result.
* @param __first An input iterator.
@@ -427,6 +428,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if __cplusplus >= 201103L
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wc++17-extensions"
+#pragma GCC diagnostic ignored "-Wclass-memaccess"
#if __glibcxx_raw_memory_algorithms >= 202411L // >= C++26
if consteval {
return std::__do_uninit_fill(__first, __last, __x);
@@ -529,6 +531,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wc++17-extensions"
+#pragma GCC diagnostic ignored "-Wclass-memaccess"
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 1339. uninitialized_fill_n should return the end of its range
/**
--
2.51.0