public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] libstdc++: Add #if around non-C++03 code in std::bitset [PR107037]
@ 2022-09-26 12:59 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2022-09-26 12:59 UTC (permalink / raw)
  To: libstdc++, gcc-patches

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

diff --git a/libstdc++-v3/include/std/bitset b/libstdc++-v3/include/std/bitset
index 6dbc58c6429..1a551cf9785 100644
--- a/libstdc++-v3/include/std/bitset
+++ b/libstdc++-v3/include/std/bitset
@@ -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
 
diff --git a/libstdc++-v3/testsuite/20_util/bitset/107037.cc b/libstdc++-v3/testsuite/20_util/bitset/107037.cc
new file mode 100644
index 00000000000..b4560dd3775
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/bitset/107037.cc
@@ -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>;
-- 
2.37.3


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-09-26 12:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-26 12:59 [committed] libstdc++: Add #if around non-C++03 code in std::bitset [PR107037] 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).