gpt4 book ai didi

c++ - ostringstream 对象创建导致我的程序崩溃

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:54:39 28 4
gpt4 key购买 nike

我的程序在创建 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

最佳答案

尝试获得更好的编译器,例如 GCC 4.8.2(或更高版本)或 clang(最新为 3.5)。

关于c++ - ostringstream 对象创建导致我的程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21685779/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com