https://gcc.gnu.org/g:874896659df65b4bdf85b3dbca0ab527bb4c920e

commit r12-10540-g874896659df65b4bdf85b3dbca0ab527bb4c920e
Author: Jonathan Wakely <jwak...@redhat.com>
Date:   Tue Jul 4 16:03:45 2023 +0100

    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)

Diff:
---
 libstdc++-v3/include/bits/stl_uninitialized.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libstdc++-v3/include/bits/stl_uninitialized.h 
b/libstdc++-v3/include/bits/stl_uninitialized.h
index 7ed69f53f7d8..88e003a30335 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.

Reply via email to