[committed] libstdc++: Add #if around non-C++03 code in std::bitset [PR107037]
Commit Message
Tested x86_64-linux, pushed to trunk.
-- >8 --
libstdc++-v3/ChangeLog:
PR libstdc++/107037
* include/std/bitset (_Base_bitset::_M_do_reset): Use
preprocessor conditional around non-C++03 code.
* testsuite/20_util/bitset/107037.cc: New test.
---
libstdc++-v3/include/std/bitset | 5 +++--
libstdc++-v3/testsuite/20_util/bitset/107037.cc | 7 +++++++
2 files changed, 10 insertions(+), 2 deletions(-)
create mode 100644 libstdc++-v3/testsuite/20_util/bitset/107037.cc
@@ -182,13 +182,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
_GLIBCXX14_CONSTEXPR void
_M_do_reset() _GLIBCXX_NOEXCEPT
{
+#if __cplusplus >= 201402L
if (__builtin_is_constant_evaluated())
{
for (_WordT& __w : _M_w)
__w = 0;
return;
}
-
+#endif
__builtin_memset(_M_w, 0, _Nw * sizeof(_WordT));
}
@@ -1680,7 +1681,7 @@ _GLIBCXX_END_NAMESPACE_VERSION
#endif // C++11
-#ifdef _GLIBCXX_DEBUG && _GLIBCXX_HOSTED
+#if defined _GLIBCXX_DEBUG && _GLIBCXX_HOSTED
# include <debug/bitset>
#endif
new file mode 100644
@@ -0,0 +1,7 @@
+// { dg-options "-std=c++03" }
+// { dg-do compile }
+// PR libstdc++/107037 bitset::_M_do_reset fails for strict -std=c++03 mode
+#include <bitset>
+template class std::bitset<0>;
+template class std::bitset<1>;
+template class std::bitset<100>;