使用boost UUID在简单函数中出现valgrind错误

时间:2015-08-16 08:41:14

标签: c++ valgrind uuid

下面的静态函数;

static std::string generateUUIDLite(){
 boost::uuids::uuid _uuid = boost::uuids::random_generator()();
 std::string str_uuid = boost::lexical_cast<std::string>(_uuid);
 size_t foundFirstSegment = str_uuid.find("-");
 return (foundFirstSegment!=std::string::npos)?str_uuid.substr(0, foundFirstSegment):str_uuid;
}

由valgrind标记为错误“未初始化的值是由堆分配创建的”以及以下内容:

==3203== Conditional jump or move depends on uninitialised value(s)
==3203==    at 0x4D0F24: chaos::common::utility::UUIDUtil::generateUUIDLite() (mersenne_twister.hpp:177)
==3203==    by 0x52F28F7: chaos::event::AsioEventForwarder::AsioEventForwarder(boost::asio::ip::address const&, unsigned short, boost::asio::io_service&) (AsioEventForwarder.cpp:33)
==3203==    by 0x52F03E7: chaos::event::AsioImplEventClient::init(void*) (AsioImplEventClient.cpp:54)
==3203==    by 0x5365F4C: chaos::common::utility::StartableService::initImplementation(chaos::common::utility::StartableService*, void*, std::string const&, std::string const&) (StartableService.cpp:73)
==3203==    by 0x533F3D8: chaos::common::network::NetworkBroker::init(void*) (NetworkBroker.cpp:152)
==3203==    by 0x5365F4C: chaos::common::utility::StartableService::initImplementation(chaos::common::utility::StartableService*, void*, std::string const&, std::string const&) (StartableService.cpp:73)
==3203==    by 0x4B5B46: chaos::data_service::ChaosDataService::init(void*) (StartableService.h:115)
==3203==    by 0x4B7A8A: chaos::data_service::ChaosDataService::init(int, char**) (ChaosCommon.h:107)
==3203==    by 0x47D526: main (main.cpp:152)

先谢谢

0 个答案:

没有答案