public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/103191] New: vector<bool> doesn't have any checks enabled by _GLIBCXX_ASSERTIONS
@ 2021-11-11 14:04 redi at gcc dot gnu.org
  2024-02-08 12:29 ` [Bug libstdc++/103191] " redi at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2021-11-11 14:04 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103191
           Summary: vector<bool> doesn't have any checks enabled by
                    _GLIBCXX_ASSERTIONS
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

We should consider this change:

diff --git a/libstdc++-v3/include/bits/stl_bvector.h
b/libstdc++-v3/include/bits/stl_bvector.h
index 1425877a5ea..32e22f5a056 100644
--- a/libstdc++-v3/include/bits/stl_bvector.h
+++ b/libstdc++-v3/include/bits/stl_bvector.h
@@ -1057,12 +1057,18 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
       reference
       operator[](size_type __n)
-      { return begin()[__n]; }
+      {
+       __glibcxx_requires_subscript(__n);
+       return begin()[__n];
+      }

       _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
       const_reference
       operator[](size_type __n) const
-      { return begin()[__n]; }
+      {
+       __glibcxx_requires_subscript(__n);
+       return begin()[__n];
+      }

     protected:
       _GLIBCXX20_CONSTEXPR
@@ -1106,22 +1112,34 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
       reference
       front()
-      { return *begin(); }
+      {
+       __glibcxx_requires_nonempty();
+       return *begin();
+      }

       _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
       const_reference
       front() const
-      { return *begin(); }
+      {
+       __glibcxx_requires_nonempty();
+       return *begin();
+      }

       _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
       reference
       back()
-      { return *(end() - 1); }
+      {
+       __glibcxx_requires_nonempty();
+       return *(end() - 1);
+      }

       _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
       const_reference
       back() const
-      { return *(end() - 1); }
+      {
+       __glibcxx_requires_nonempty();
+       return *(end() - 1);
+      }

       // _GLIBCXX_RESOLVE_LIB_DEFECTS
       // DR 464. Suggestion for new member functions in standard containers.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-06-27  9:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-11 14:04 [Bug libstdc++/103191] New: vector<bool> doesn't have any checks enabled by _GLIBCXX_ASSERTIONS redi at gcc dot gnu.org
2024-02-08 12:29 ` [Bug libstdc++/103191] " redi at gcc dot gnu.org
2024-06-18 20:12 ` redi at gcc dot gnu.org
2024-06-27  8:42 ` cvs-commit at gcc dot gnu.org
2024-06-27  9:04 ` redi at gcc dot gnu.org

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).