我的程序在创建ostringstream类的对象时总是崩溃。我无法理解是什么导致它崩溃?
#include <string>
#include <sstream>
#include <iostream>
DDF foo::send(const DDF& in)
{
ostringstream os; <-- causing crash always
os << in;
string ostr(os.str());
..
}
backtrace of the core
=================
Breakpoint 1, DDF foo::send (this=0x7244f48, in=@0x5496760) at foo.cpp:290
290 DDF foo::send(const DDF& in)
Current language: auto; currently c++
(gdb) n
456 _M_streambuf(0), _M_ctype(0), _M_num_put(0), _M_num_get(0)
(gdb)
Program received signal SIGSEGV, Segmentation fault.
0x00007f897cd7df9c in std::locale::_S_initialize () from /usr/lib64/libstdc++.so.6
(gdb) bt
#0 0x00007f897cd7df9c in std::locale::_S_initialize () from /usr/lib64/libstdc++.so.6
#1 0x00007f897cd7e005 in std::locale::locale () from /usr/lib64/libstdc++.so.6
#2 0x00007f897de70760 in foo::send (this=0x7244f48, in=@0x7f897cd7df40)
at /opt/gcc-4.3.2/lib64/gcc/x86_64-unknown-linux-gnu/4.3.2/../../../../include/c++/4.3.2/bits/basic_ios.h:456
答案 0 :(得分:0)
尝试获得更好的编译器,如GCC 4.8.2(或更高版本)或clang(最新版本为3.5)。