From bfbc811b25945fa82138ab678f4e1418726c45df Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Thu, 19 May 2005 09:59:46 +0100 Subject: [PATCH] basic_string.h (operator[]): Allow s[s.size()] in debug mode, but not pedantic mode. * include/bits/basic_string.h (operator[]): Allow s[s.size()] in debug mode, but not pedantic mode. From-SVN: r99967 --- libstdc++-v3/ChangeLog | 5 +++++ libstdc++-v3/include/bits/basic_string.h | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 08ff5caa882..ff614e30eed 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,8 @@ +2005-05-19 Jonathan Wakely + + * include/bits/basic_string.h (operator[]): Allow s[s.size()] in + debug mode, but not pedantic mode. + 2005-05-19 Jan Beulich * libsupc++/unwind-cxx.h: Include cstdlib. diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h index b1fbaaac4d0..35dd364d969 100644 --- a/libstdc++-v3/include/bits/basic_string.h +++ b/libstdc++-v3/include/bits/basic_string.h @@ -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]; } -- 2.30.2