OSDN Git Service

* include/bits/basic_string.h (operator[]): Allow s[s.size()] in
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 19 May 2005 08:59:46 +0000 (08:59 +0000)
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 19 May 2005 08:59:46 +0000 (08:59 +0000)
debug mode, but not pedantic mode.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@99967 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 08ff5ca..ff614e3 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 b1fbaaa..35dd364 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];
       }