* [committed] libstdc++: Fix std::__uninitialized_default_n for constant evaluation [PR110542]
@ 2023-07-05 6:40 Jonathan Wakely
0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2023-07-05 6:40 UTC (permalink / raw)
To: libstdc++, gcc-patches
This is a weird one as described in the PR. GCC doesn't complain about
this bug, but seems to have a bogus error elsewhere. I'll add a testcase
once I've understood/fixed the GCC error.
Tested x86_64-linux. Pushed to trunk.
-- >8 --
libstdc++-v3/ChangeLog:
PR libstdc++/110542
* include/bits/stl_uninitialized.h (__uninitialized_default_n):
Do not use std::fill_n during constant evaluation.
---
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 6752c6b5746..be7b4afdd05 100644
--- a/libstdc++-v3/include/bits/stl_uninitialized.h
+++ b/libstdc++-v3/include/bits/stl_uninitialized.h
@@ -695,6 +695,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.
--
2.41.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-07-05 6:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-05 6:40 [committed] libstdc++: Fix std::__uninitialized_default_n for constant evaluation [PR110542] Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).