public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: "François Dumont" <frs.dumont@gmail.com>
To: "libstdc++@gcc.gnu.org" <libstdc++@gcc.gnu.org>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [PATCH][_GLIBCXX_ASSERTIONS] Activate __glibcxx_requires_string/__glibcxx_requires_string_len
Date: Tue, 16 Aug 2022 20:54:09 +0200	[thread overview]
Message-ID: <285077ef-de58-6050-bba8-e59f01009c8b@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1455 bytes --]

Following my remark about tests XFAIL-ing when running 'make check' I'd 
like to propose this to avoid this situation.

     libstdc++: [_GLIBCXX_ASSERTIONS] Activate basic 
_GLIBCXX_DEBUB_PEDANTIC checks

     Activate __glibcxx_requires_string/__glibcxx_requires_string_len in 
basic _GLIBCXX_ASSERTIONS
     mode which is then considering _GLIBCXX_DEBUG_PEDANTIC for this 
purpose.

     Thanks to this change add _GLIBCXX_ASSERTIONS to some tests that 
are otherwise XFAIL-ing on
     segmentation fault rather than on a proper __glibcxx_assert call.

     libstdc++-v3/ChangeLog:

             * include/debug/debug.h (__glibcxx_requires_string, 
__glibcxx_requires_string_len): Move
             definitions...
             * include/debug/assertions.h: ... here. Definition now 
depends on _GLIBCXX_ASSERTIONS rather
             than _GLIBCXX_DEBUG.
             * 
testsuite/21_strings/basic_string/operations/ends_with/char_neg.cc: Add 
_GLIBCXX_ASSERTIONS
             define.
             * 
testsuite/21_strings/basic_string/operations/ends_with/wchar_t_neg.cc: 
Likewise.
             * 
testsuite/21_strings/basic_string/operations/starts_with/char_neg.cc: 
Likewise.
             * 
testsuite/21_strings/basic_string/operations/starts_with/wchar_t_neg.cc: 
Likewise.

Tested under Linux x86_64.

Ok to commit ?

François

[-- Attachment #2: string_assertions.patch --]
[-- Type: text/x-patch, Size: 5622 bytes --]

diff --git a/libstdc++-v3/include/debug/assertions.h b/libstdc++-v3/include/debug/assertions.h
index 57c0ab2c3cf..fcc910c7396 100644
--- a/libstdc++-v3/include/debug/assertions.h
+++ b/libstdc++-v3/include/debug/assertions.h
@@ -43,6 +43,8 @@
 # define __glibcxx_requires_non_empty_range(_First,_Last)
 # define __glibcxx_requires_nonempty()
 # define __glibcxx_requires_subscript(_N)
+# define __glibcxx_requires_string(_String)
+# define __glibcxx_requires_string_len(_String,_Len)
 #else
 
 // Verify that [_First, _Last) forms a non-empty iterator range.
@@ -53,6 +55,22 @@
 // Verify that the container is nonempty
 # define __glibcxx_requires_nonempty()		\
   __glibcxx_assert(!this->empty())
+# ifdef _GLIBCXX_DEBUG_PEDANTIC
+#  if __cplusplus < 201103L
+#   define __glibcxx_requires_string(_String)	\
+  __glibcxx_assert(_String != 0)
+#   define __glibcxx_requires_string_len(_String,_Len)	\
+  __glibcxx_assert(_String != 0 || _Len == 0)
+#  else
+#   define __glibcxx_requires_string(_String)	\
+  __glibcxx_assert(_String != nullptr)
+#   define __glibcxx_requires_string_len(_String,_Len)	\
+  __glibcxx_assert(_String != nullptr || _Len == 0)
+#  endif // C++11
+# else
+#  define __glibcxx_requires_string(_String)
+#  define __glibcxx_requires_string_len(_String,_Len)
+# endif // _GLIBCXX_DEBUG_PEDANTIC
 #endif
 
 #ifdef _GLIBCXX_DEBUG
diff --git a/libstdc++-v3/include/debug/debug.h b/libstdc++-v3/include/debug/debug.h
index f4233760426..5593b4fe92c 100644
--- a/libstdc++-v3/include/debug/debug.h
+++ b/libstdc++-v3/include/debug/debug.h
@@ -78,8 +78,6 @@ namespace __gnu_debug
 # define __glibcxx_requires_partitioned_upper_pred(_First,_Last,_Value,_Pred)
 # define __glibcxx_requires_heap(_First,_Last)
 # define __glibcxx_requires_heap_pred(_First,_Last,_Pred)
-# define __glibcxx_requires_string(_String)
-# define __glibcxx_requires_string_len(_String,_Len)
 # define __glibcxx_requires_irreflexive(_First,_Last)
 # define __glibcxx_requires_irreflexive2(_First,_Last)
 # define __glibcxx_requires_irreflexive_pred(_First,_Last,_Pred)
@@ -118,17 +116,6 @@ namespace __gnu_debug
   __glibcxx_check_heap(_First,_Last)
 # define __glibcxx_requires_heap_pred(_First,_Last,_Pred)	\
   __glibcxx_check_heap_pred(_First,_Last,_Pred)
-# if __cplusplus < 201103L
-#  define __glibcxx_requires_string(_String)	\
-  _GLIBCXX_DEBUG_PEDASSERT(_String != 0)
-#  define __glibcxx_requires_string_len(_String,_Len)	\
-  _GLIBCXX_DEBUG_PEDASSERT(_String != 0 || _Len == 0)
-# else
-#  define __glibcxx_requires_string(_String)	\
-  _GLIBCXX_DEBUG_PEDASSERT(_String != nullptr)
-#  define __glibcxx_requires_string_len(_String,_Len)	\
-  _GLIBCXX_DEBUG_PEDASSERT(_String != nullptr || _Len == 0)
-# endif
 # define __glibcxx_requires_irreflexive(_First,_Last)	\
   __glibcxx_check_irreflexive(_First,_Last)
 # define __glibcxx_requires_irreflexive2(_First,_Last)	\
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/ends_with/char_neg.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/ends_with/char_neg.cc
index 7a7b8dd077d..6080ddc0555 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/operations/ends_with/char_neg.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/ends_with/char_neg.cc
@@ -15,7 +15,7 @@
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 //
-// { dg-options "-std=gnu++2a -O0" }
+// { dg-options "-std=gnu++2a -D_GLIBCXX_ASSERTIONS" }
 // { dg-do run { target c++2a xfail *-*-* } }
 
 #define _GLIBCXX_DEBUG_PEDANTIC
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/ends_with/wchar_t_neg.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/ends_with/wchar_t_neg.cc
index a6881bf406b..61d43558a74 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/operations/ends_with/wchar_t_neg.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/ends_with/wchar_t_neg.cc
@@ -15,7 +15,7 @@
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 //
-// { dg-options "-std=gnu++2a -O0" }
+// { dg-options "-std=gnu++2a -D_GLIBCXX_ASSERTIONS" }
 // { dg-do run { target c++2a xfail *-*-* } }
 
 #define _GLIBCXX_DEBUG_PEDANTIC
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/starts_with/char_neg.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/starts_with/char_neg.cc
index f357aef2289..e1cc8bad525 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/operations/starts_with/char_neg.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/starts_with/char_neg.cc
@@ -15,7 +15,7 @@
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 //
-// { dg-options "-std=gnu++2a -O0" }
+// { dg-options "-std=gnu++2a -D_GLIBCXX_ASSERTIONS" }
 // { dg-do run { target c++2a xfail *-*-* } }
 
 #define _GLIBCXX_DEBUG_PEDANTIC
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/starts_with/wchar_t_neg.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/starts_with/wchar_t_neg.cc
index 90065a459b6..8fc39bbd63c 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/operations/starts_with/wchar_t_neg.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/starts_with/wchar_t_neg.cc
@@ -15,7 +15,7 @@
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 //
-// { dg-options "-std=gnu++2a -O0" }
+// { dg-options "-std=gnu++2a -D_GLIBCXX_ASSERTIONS" }
 // { dg-do run { target c++2a xfail *-*-* } }
 
 #define _GLIBCXX_DEBUG_PEDANTIC

                 reply	other threads:[~2022-08-16 18:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=285077ef-de58-6050-bba8-e59f01009c8b@gmail.com \
    --to=frs.dumont@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).