This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[v3] Small tweak to ext/vstring.h
- From: Paolo Carlini <pcarlini at suse dot de>
- To: "'gcc-patches at gcc dot gnu dot org'" <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 28 Mar 2006 14:56:16 +0200
- Subject: [v3] Small tweak to ext/vstring.h
Hi,
tested x86-linux, committed mainline & 4_1-branch.
Paolo.
///////////////
2006-03-28 Paolo Carlini <pcarlini@suse.de>
* include/ext/vstring.h (operator[]): Allow s[s.size()] in
debug mode, but not pedantic mode.
Index: include/ext/vstring.h
===================================================================
--- include/ext/vstring.h (revision 112441)
+++ include/ext/vstring.h (working copy)
@@ -449,7 +449,10 @@
reference
operator[](size_type __pos)
{
- _GLIBCXX_DEBUG_ASSERT(__pos < this->size());
+ // allow pos == size() as v3 extension:
+ _GLIBCXX_DEBUG_ASSERT(__pos <= this->size());
+ // but be strict in pedantic mode:
+ _GLIBCXX_DEBUG_PEDASSERT(__pos < this->size());
this->_M_leak();
return this->_M_data()[__pos];
}