aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2023-07-04 16:03:45 +0100
committerJonathan Wakely <jwakely@redhat.com>2024-06-11 13:21:51 +0100
commit874896659df65b4bdf85b3dbca0ab527bb4c920e (patch)
tree6694894e643626cf21690cd27f4d3044b3d2359b
parent6f0bd7cfb3288b667ab8e8ec18984a67c4238a86 (diff)
downloadgcc-874896659df65b4bdf85b3dbca0ab527bb4c920e.zip
gcc-874896659df65b4bdf85b3dbca0ab527bb4c920e.tar.gz
gcc-874896659df65b4bdf85b3dbca0ab527bb4c920e.tar.bz2
libstdc++: Fix std::__uninitialized_default_n for constant evaluation [PR110542]
libstdc++-v3/ChangeLog: PR libstdc++/110542 * include/bits/stl_uninitialized.h (__uninitialized_default_n): Do not use std::fill_n during constant evaluation. (cherry picked from commit 83cae6c4b788544635a71748e1881c150f42efef)
-rw-r--r--libstdc++-v3/include/bits/stl_uninitialized.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/libstdc++-v3/include/bits/stl_uninitialized.h b/libstdc++-v3/include/bits/stl_uninitialized.h
index 7ed69f5..88e003a 100644
--- a/libstdc++-v3/include/bits/stl_uninitialized.h
+++ b/libstdc++-v3/include/bits/stl_uninitialized.h
@@ -690,6 +690,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
inline _ForwardIterator
__uninitialized_default_n(_ForwardIterator __first, _Size __n)
{
+#ifdef __cpp_lib_is_constant_evaluated
+ if (std::is_constant_evaluated())
+ return __uninitialized_default_n_1<false>::
+ __uninit_default_n(__first, __n);
+#endif
+
typedef typename iterator_traits<_ForwardIterator>::value_type
_ValueType;
// See uninitialized_fill_n for the conditions for using std::fill_n.