This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/25288] New: std::list insert members should have no effects if an exception is thrown
- From: "lennox at cs dot columbia dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 6 Dec 2005 21:28:58 -0000
- Subject: [Bug libstdc++/25288] New: std::list insert members should have no effects if an exception is thrown
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
According to section 23.2.2.3 [lib.list.modifiers] of the C++ specification,
for all the insert member functions of std::list, "If an exception is thrown
there are no effects."
However, this doesn't appear to be the case for libstdc++. It's possible for
an exception to be thrown out of an insert() function (e.g. bad_alloc from an
allocator) and still have the list change.
$ g++40 -v -g -O2 -Wall debug_allocate.cpp -o debug_allocate
Using built-in specs.
Target: i386-portbld-freebsd5.4
Configured with: ./..//gcc-4.0-20050929/configure --disable-nls
--with-system-zlib --with-libiconv-prefix=/usr/local --program-suffix=40
--libdir=/usr/local/lib/gcc/i386-portbld-freebsd5.4/4.0.3
--with-gxx-include-dir=/usr/local/lib/gcc/i386-portbld-freebsd5.4/4.0.3/include/c++/
--with-gmp=/usr/local --disable-shared --prefix=/usr/local
i386-portbld-freebsd5.4
Thread model: posix
gcc version 4.0.3 20050928 (prerelease) [FreeBSD]
/usr/local/libexec/gcc/i386-portbld-freebsd5.4/4.0.3/cc1plus -quiet -v
debug_allocate.cpp -quiet -dumpbase debug_allocate.cpp -auxbase debug_allocate
-g -O2 -Wall -version -o /var/tmp//cc9cvkJd.s
ignoring nonexistent directory
"/usr/local/lib/gcc/i386-portbld-freebsd5.4/4.0.3/gcc/i386-portbld-freebsd5.4/4.0.3/../../../../i386-portbld-freebsd5.4/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/lib/gcc/i386-portbld-freebsd5.4/4.0.3/include/c++/
/usr/local/lib/gcc/i386-portbld-freebsd5.4/4.0.3/include/c++//i386-portbld-freebsd5.4
/usr/local/lib/gcc/i386-portbld-freebsd5.4/4.0.3/include/c++//backward
/usr/local/include
/usr/local/lib/gcc/i386-portbld-freebsd5.4/4.0.3/gcc/i386-portbld-freebsd5.4/4.0.3/include
/usr/include
End of search list.
GNU C++ version 4.0.3 20050928 (prerelease) [FreeBSD] (i386-portbld-freebsd5.4)
compiled by GNU C version 4.0.3 20050928 (prerelease) [FreeBSD].
GGC heuristics: --param ggc-min-expand=99 --param ggc-min-heapsize=129460
as -o /var/tmp//ccljCm8j.o /var/tmp//cc9cvkJd.s
/usr/local/libexec/gcc/i386-portbld-freebsd5.4/4.0.3/collect2 -V
-dynamic-linker /usr/libexec/ld-elf.so.1 -o debug_allocate /usr/lib/crt1.o
/usr/lib/crti.o
/usr/local/lib/gcc/i386-portbld-freebsd5.4/4.0.3/gcc/i386-portbld-freebsd5.4/4.0.3/crtbegin.o
-L/usr/local/lib/gcc/i386-portbld-freebsd5.4/4.0.3/gcc/i386-portbld-freebsd5.4/4.0.3
-L/usr/local/lib/gcc/i386-portbld-freebsd5.4/4.0.3/gcc/i386-portbld-freebsd5.4/4.0.3/../../..
/var/tmp//ccljCm8j.o -lstdc++ -lm -lgcc -lc -lgcc
/usr/local/lib/gcc/i386-portbld-freebsd5.4/4.0.3/gcc/i386-portbld-freebsd5.4/4.0.3/crtend.o
/usr/lib/crtn.o
GNU ld version 2.15 [FreeBSD] 2004-05-23
Supported emulations:
elf_i386_fbsd
$ ./debug_allocate
Caught exception: St9bad_alloc
List size: 5
(I'll attach the test programs immediately after submitting the bug.)
--
Summary: std::list insert members should have no effects if an
exception is thrown
Product: gcc
Version: 4.0.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: lennox at cs dot columbia dot edu
GCC build triplet: i386-portbld-freebsd5.4
GCC host triplet: i386-portbld-freebsd5.4
GCC target triplet: i386-portbld-freebsd5.4
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25288