#include
int main()
{
std::string s = "foo";
s[3]; // doesn't throw and should
}
when compiled with g++ -D_GLIBCXX_DEBUG doesn't throw but should. It does
throw with s[4] and s[-1], however.
test$ g++ -D_GLIBCXX_DEBUG gccbug.cpp && ./a.out
test$ g++ -v
Using built-in specs.
Target: i586-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla
--enable-bootstrap --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk
--disable-dssi --enable-plugin
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre
--enable-libgcj-multifile --enable-java-maintainer-mode
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib
--with-ppl --with-cloog --with-tune=generic --with-arch=i586
--build=i586-redhat-linux
Thread model: posix
gcc version 4.4.1 20090725 (Red Hat 4.4.1-2) (GCC) test
$ uname -a
Linux maisy.oxyware.net 2.6.30.10-105.fc11.i686.PAE #1 SMP Thu Dec 24 16:41:17
UTC 2009 i686 i686 i386 GNU/Linux
Fedora Core 11, 32-bit Intel x86, using distro rpm
test$ rpm -q gcc
gcc-4.4.1-2.fc11.i586
--
Summary: GLIBCXX_DEBUG off-by-one error for std::string
operator[]
Product: gcc
Version: 4.4.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gccbug at oxyware dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42673