aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/ext/vstring.h
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2013-08-15 00:15:12 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2013-08-15 00:15:12 +0000
commit56b5d3b48bce83cd429befde35933f5105df21e2 (patch)
tree00fc9c8d2a7b382b142a966c9bce9fcdbaef0e0f /libstdc++-v3/include/ext/vstring.h
parent715a572a8a19d90b8dc02601adbae32a1a78652d (diff)
downloadgcc-56b5d3b48bce83cd429befde35933f5105df21e2.zip
gcc-56b5d3b48bce83cd429befde35933f5105df21e2.tar.gz
gcc-56b5d3b48bce83cd429befde35933f5105df21e2.tar.bz2
re PR libstdc++/58163 ([C++11] Pedantic assert on str[str.size()] is wrong in C++11)
2013-08-14 Paolo Carlini <paolo.carlini@oracle.com> 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
Diffstat (limited to 'libstdc++-v3/include/ext/vstring.h')
-rw-r--r--libstdc++-v3/include/ext/vstring.h8
1 files changed, 5 insertions, 3 deletions
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];
}