From 56b5d3b48bce83cd429befde35933f5105df21e2 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Thu, 15 Aug 2013 00:15:12 +0000 Subject: re PR libstdc++/58163 ([C++11] Pedantic assert on str[str.size()] is wrong in C++11) 2013-08-14 Paolo Carlini PR libstdc++/58163 * include/bits/basic_string.h (basic_string<>::operator[]): Fix _GLIBCXX_DEBUG_PEDASSERT check vs C++11. * include/ext/vstring.h: Likewise. * testsuite/21_strings/basic_string/element_access/char/58163.cc: New. * testsuite/21_strings/basic_string/element_access/wchar_t/58163.cc: Likewise. * testsuite/ext/vstring/element_access/char/58163.cc: Likewise. * testsuite/ext/vstring/element_access/wchar_t/58163.cc: Likewise. From-SVN: r201755 --- libstdc++-v3/include/ext/vstring.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'libstdc++-v3/include/ext/vstring.h') diff --git a/libstdc++-v3/include/ext/vstring.h b/libstdc++-v3/include/ext/vstring.h index 43edb53..8532213 100644 --- a/libstdc++-v3/include/ext/vstring.h +++ b/libstdc++-v3/include/ext/vstring.h @@ -557,10 +557,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION reference operator[](size_type __pos) { - // allow pos == size() as v3 extension: + // Allow pos == size() both in C++98 mode, as v3 extension, + // and in C++11 mode. _GLIBCXX_DEBUG_ASSERT(__pos <= this->size()); - // but be strict in pedantic mode: - _GLIBCXX_DEBUG_PEDASSERT(__pos < this->size()); + // In pedantic mode be strict in C++98 mode. + _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L + || __pos < this->size()); this->_M_leak(); return this->_M_data()[__pos]; } -- cgit v1.1