This is the mail archive of the
libstdc++@sources.redhat.com
mailing list for the libstdc++ project.
`cout << setw(...) << "..."' gives segfault
- To: libstdc++ at sources dot redhat dot com
- Subject: `cout << setw(...) << "..."' gives segfault
- From: Petter Urkedal <petter dot urkedal at matfys dot lth dot se>
- Date: Mon, 16 Oct 2000 17:41:10 +0200
The current CVS gcc/libstdc++-v3 gives segmentation fault when a setw()
is applied to a C string. Can you reproduce this? Is it a code
generation thing? -- GDB seems really confused at stackframe #4, and
the relevant part of the v3 source seems fine to me (dosn't mean it is).
Cheers,
-petter.
[---]$ g++ -v
Reading specs from /usr/nilsson/devel/lib/gcc-lib/i686-pc-linux-gnu/2.97/specs
Configured with: --enable-libstdcxx-v3 --prefix=/usr/nilsson/devel
gcc version 2.97 20001013 (experimental)
[---]$ uname -a
Linux nilsson 2.2.16 #1 Wed Aug 2 20:03:33 GMT 2000 i686 unknown
[---]$ cat setw_segfault.cc
#include <iostream>
#include <iomanip>
int
main()
{
std::cout << std::setw(14) << "EW" << std::endl;
return 0;
}
[---]$ g++ -g setw_segfault.cc
[---]$ gdb ./a.out
GNU gdb 5.0
Copyright 2000 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 "i686-pc-linux-gnu"...
(gdb) r
Starting program: /usr/users/petter/tmp/./a.out
Program received signal SIGSEGV, Segmentation fault.
0x4016b007 in memcpy (dstpp=0x804a860, srcpp=0xbfff0006, len=14)
at ../sysdeps/generic/memcpy.c:55
55 ../sysdeps/generic/memcpy.c: No such file or directory.
Current language: auto; currently c
(gdb) bt
#0 0x4016b007 in memcpy (dstpp=0x804a860, srcpp=0xbfff0006, len=14)
at ../sysdeps/generic/memcpy.c:55
#1 0x4009348d in std::basic_streambuf<char, std::char_traits<char>
>::xsputn (
this=0x804a6d0, __s=0xbfff0006 "", __n=14)
at ../../../../../src/gcc/libstdc++-v3/include/bits/char_traits.h:187
#2 0x400be537 in std::basic_filebuf<char, std::char_traits<char> >::xsputn
(
this=0x804a6d0, __s=0xbfff0006 "", __n=14)
at ../../../../../src/gcc/libstdc++-v3/include/bits/std_fstream.h:224
#3 0x400afda8 in std::basic_ostream<char, std::char_traits<char> >::write
(
this=0x804a170, __s=0xbfff0006 "", __n=14)
at ../../../../../src/gcc/libstdc++-v3/include/bits/std_streambuf.h:352
#4 0x400b118d in std::basic_ostream<char, std::char_traits<char> > &
std::operator<<<std::char_traits<char> > (__out=@0x804a170, __s=0x8048f30
"EW")
at ../../../../../src/gcc/libstdc++-v3/include/bits/std_ostream.h:648
#5 0x8048d50 in main () at setw_segfault.cc:7
#6 0x4012ba8e in __libc_start_main (main=0x8048d10 <main>, argc=1,
argv=0xbffff2c4, init=0x8048b2c <_init>, fini=0x8048f0c <_fini>,
rtld_fini=0x4000aa20 <_dl_fini>, stack_end=0xbffff2bc)
at ../sysdeps/generic/libc-start.c:92