https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111250

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Something like this (with new/improved tests):

--- a/libstdc++-v3/include/debug/assertions.h
+++ b/libstdc++-v3/include/debug/assertions.h
@@ -31,15 +31,16 @@

 #include <bits/c++config.h>

-#ifndef _GLIBCXX_ASSERTIONS
-# define __glibcxx_requires_non_empty_range(_First,_Last)
-# define __glibcxx_requires_nonempty()
-# define __glibcxx_requires_subscript(_N)
+#ifdef _GLIBCXX_DEBUG
+# define __glibcxx_requires_non_empty_range(_First,_Last) \
+  __glibcxx_check_non_empty_range(_First, _Last)
+# define __glibcxx_requires_nonempty() __glibcxx_check_nonempty()
+# define __glibcxx_requires_subscript(_N) __glibcxx_check_subscript(_N)
 #else
-
 // Verify that [_First, _Last) forms a non-empty iterator range.
 # define __glibcxx_requires_non_empty_range(_First,_Last)      \
   __glibcxx_assert(_First != _Last)
+// Verify that N is a valid index into *this.
 # define __glibcxx_requires_subscript(_N)      \
   __glibcxx_assert(_N < this->size())
 // Verify that the container is nonempty


This change would use the more verbose, user-friendly assertions for the full
debug mode, and unconditionally use __glibcxx_assert otherwise.

Reply via email to