basic_string.h (operator[]): Allow s[s.size()] in debug mode, but not pedantic mode.
authorJonathan Wakely <redi@gcc.gnu.org>
Thu, 19 May 2005 08:59:46 +0000 (09:59 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 19 May 2005 08:59:46 +0000 (09:59 +0100)
* include/bits/basic_string.h (operator[]): Allow s[s.size()] in
debug mode, but not pedantic mode.

From-SVN: r99967

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/basic_string.h

index 08ff5caa8824e6567c07d81c88470dc633d33193..ff614e30eed3b613f74a85a981eb22a726d65ea5 100644 (file)
@@ -1,3 +1,8 @@
+2005-05-19  Jonathan Wakely  <redi@gcc.gnu.org>
+
+       * include/bits/basic_string.h (operator[]): Allow s[s.size()] in
+       debug mode, but not pedantic mode.
+
 2005-05-19  Jan Beulich  <jbeulich@novell.com>
 
        * libsupc++/unwind-cxx.h: Include cstdlib.
index b1fbaaac4d0837fc19fcc07b5e62d3b7558f1cf7..35dd364d969b53ecd6daa56dc041f6147bcdf4f4 100644 (file)
@@ -695,7 +695,10 @@ namespace std
       reference
       operator[](size_type __pos)
       {
-       _GLIBCXX_DEBUG_ASSERT(__pos < size());
+        // allow pos == size() as v3 extension:
+       _GLIBCXX_DEBUG_ASSERT(__pos <= size());
+        // but be strict in pedantic mode:
+       _GLIBCXX_DEBUG_PEDASSERT(__pos < size());
        _M_leak();
        return _M_data()[__pos];
       }