Copy and paste at prompt:
$ cat t.xpp
#include <cstddef>
#include <deque>
struct A { char tmp [32]; };
int main ()
{
A a [32];
std::deque<A> lhs (a, a + 0);
std::deque<A> rhs (a, a + 1);
lhs.swap (rhs);
return 0;
}
Building and running the example leads to a SIGSEGV:
$ make SRCS=t.cpp && ./t
gcc -c -I/build/nicoara/stdcxx/include/ansi -D_RWSTDDEBUG -pthread -D_RWSTD_USE_CONFIG -I/build/nicoara/15s-stdcxx/include -I/build/nicoara/stdcxx/include -I/build/nicoara/stdcxx/../rwtest -I/build/nicoara/stdcxx/../rwtest/include -I/build/nicoara/stdcxx/tests/include -pedantic -nostdinc++ -g -W -Wall -Wcast-qual -Winline -Wshadow -Wwrite-strings -Wno-long-long -Wcast-align /build/nicoara/stdcxx/tests/containers/t.cpp
gcc t.o -o t -L/build/nicoara/15s-stdcxx/rwtest -lrwtest15s -pthread -L/build/nicoara/15s-stdcxx/lib -lstd15s -lsupc++ -lm
Segmentation fault
$ gdb t
GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i486-slackware-linux"...Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) r
Starting program: /build/nicoara/15s-stdcxx/tests/t
[Thread debugging using libthread_db enabled]
[New Thread 16384 (LWP 7497)]
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 16384 (LWP 7497)]
0x0804ba87 in std::copy<_rw::rw_debug_iter<std::deque<A, std::allocator<A> >, std::rw_deque_iter<A, int, A*, A&, std::allocator<A> >, std::rw_deque_iter<A, int, A*, A&, std::allocator<A> > >, __rw::rw_debug_iter<std::deque<A, std::allocator<A> >, std::rw_deque_iter<A, int, A*, A&, std::allocator<A> >, std::rw_deque_iter<A, int, A*, A&, std::allocator<A> > > > (_first=@0xbfd52c54, __last=@0xbfd52c48,
__res=@0xbfd52c3c) at _algobase.h:88
88 *_res = *_first;
(gdb) bt
#0 0x0804ba87 in std::copy<_rw::rw_debug_iter<std::deque<A, std::allocator<A> >, std::rw_deque_iter<A, int, A*, A&, std::allocator<A> >, std::rw_deque_iter<A, int, A*, A&, std::allocator<A> > >, __rw::rw_debug_iter<std::deque<A, std::allocator<A> >, std::rw_deque_iter<A, int, A*, A&, std::allocator<A> >, std::rw_deque_iter<A, int, A*, A&, std::allocator<A> > > > (_first=@0xbfd52c54,
__last=@0xbfd52c48, __res=@0xbfd52c3c) at _algobase.h:88
#1 0x0804be6b in std::deque<A, std::allocator<A> >::erase (this=0xbfd53130,
__first=@0xbfd52ca8, __last=@0xbfd52c9c) at deque.cc:158
#2 0x0804bf7d in std::deque<A, std::allocator<A> >::clear (this=0xbfd53130)
at deque:644
#3 0x0804c028 in ~deque (this=0xbfd53130) at deque:476
#4 0x08049d30 in main () at /build/nicoara/stdcxx/tests/containers/t.cpp:15
(gdb)