I have a patch for the same location so here is my remark that might
make my patch useless.
Maybe you can even merge it with yours Ed, here it is:
https://gcc.gnu.org/ml/libstdc++/2019-10/msg00072.html
On 11/25/19 10:15 PM, Jonathan Wakely wrote:
On 15/11/19 22:17 -0500, Ed Smith-Rowland via libstdc++ wrote:
Index: include/bits/stl_algobase.h
===================================================================
--- include/bits/stl_algobase.h (revision 278318)
+++ include/bits/stl_algobase.h (working copy)
@@ -107,6 +107,50 @@
}
/*
+ * A constexpr wrapper for __builtin_memmove.
This should say __builtin_memcpy.
+ * @param __num The number of elements of type _Tp (not bytes).
+ */
+ template<typename _Tp>
+ _GLIBCXX14_CONSTEXPR
+ inline void*
+ __memcpy(_Tp* __dst, const _Tp* __src, size_t __num)
+ {
+#ifdef __cpp_lib_is_constant_evaluated
+ if (std::is_constant_evaluated())
+ {
+ for(; __num > 0; --__num)
for (; __num != 0; --__num)
and make __num prtdiff_t.
would be better here as this way the compiler is able to report bad
usages rather than silently do nothing.
+ *__dst++ = *__src++;
+ return __dst;
+ }
+ else
+#endif
+ return __builtin_memcpy(__dst, __src, sizeof(_Tp) * __num);
+ return __dst;
+ }
+
+ /*
+ * A constexpr wrapper for __builtin_memmove.
And this should say __builtin_memset.
+ * @param __num The number of elements of type _Tp (not bytes).
+ */
+ template<typename _Tp>
+ _GLIBCXX14_CONSTEXPR
+ inline void*
+ __memset(_Tp* __dst, _Tp __a, size_t __num)
+ {
+#ifdef __cpp_lib_is_constant_evaluated
+ if (std::is_constant_evaluated())
+ {
+ for(; __num > 0; --__num)
+ *__dst = __a;
+ return __dst;
+ }
+ else
+#endif
+ return __builtin_memset(__dst, __a, sizeof(_Tp) * __num);
+ return __dst;
+ }
OK for trunk with those two comment fixes. Thanks.