Analysis of Valgrind log for boost::uuid

前端 未结 1 921
鱼传尺愫
鱼传尺愫 2021-01-22 22:44

I am using boost::uuid in order to generate unique ids:

string UUid()
{
    boost::uuids::uuid uuid = boost::uuids::random_generator()();
    return boost::lexica         


        
相关标签:
1条回答
  • 2021-01-22 22:56

    Please check http://www.boost.org/doc/libs/1_50_0/libs/uuid/uuid.html

    The boost::uuids::basic_random_generator class default constructor seeds the random number generator with a SHA-1 hash of a number of different values including std::time(0), std::clock(), **uninitialized data**, value return from new unsigned int, etc..

    ...Using Valgrind produces a number of false positives with the default constructor of boost::uuids::basic_random_generator. One solution is to suppress the errors as described in Valgrind's documentation. Another solution is to use a different constructor of boost::uuids::basic_random_generator and explicitly pass in a random number generator.

    0 讨论(0)
提交回复
热议问题