* [PATCH][_GLIBCXX_ASSERTIONS] Activate __glibcxx_requires_string/__glibcxx_requires_string_len
@ 2022-08-16 18:54 François Dumont
0 siblings, 0 replies; only message in thread
From: François Dumont @ 2022-08-16 18:54 UTC (permalink / raw)
To: libstdc++; +Cc: gcc-patches
[-- 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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-08-16 18:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-16 18:54 [PATCH][_GLIBCXX_ASSERTIONS] Activate __glibcxx_requires_string/__glibcxx_requires_string_len François Dumont
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).