Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7763335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:38:00+00:00 2026-06-01T14:38:00+00:00

I have a class with members: std::string mName; boost::uuids::uuid mId; In the constructor I

  • 0

I have a class with members:

std::string mName;
boost::uuids::uuid mId;

In the constructor I wrote:

mName = boost::lexical_cast<std::string>(mId);

Valgrind writes:

==30714== Use of uninitialised value of size 8
==30714==    at 0x69E92FC: ??? (in /usr/lib/libstdc++.so.6.0.16)
==30714==    by 0x69E93EE: std::ostreambuf_iterator<char, std::char_traits<char> > std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > >::_M_insert_int<unsigned long>(std::ostreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, char, unsigned long) const (in /usr/lib/libstdc++.so.6.0.16)
==30714==    by 0x69E9705: std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > >::do_put(std::ostreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, char, unsigned long) const (in /usr/lib/libstdc++.so.6.0.16)
==30714==    by 0x69F522C: std::ostream& std::ostream::_M_insert<unsigned long>(unsigned long) (in /usr/lib/libstdc++.so.6.0.16)
==30714==    by 0x6283A5: std::basic_ostream<char, std::char_traits<char> >& boost::uuids::operator<< <char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, boost::uuids::uuid const&) (uuid_io.hpp:55)
==30714==    by 0x62799D: bool boost::detail::lexical_stream_limited_src<char, std::char_traits<char>, true>::shl_input_streamable<boost::uuids::uuid const>(boost::uuids::uuid const&) (lexical_cast.hpp:1260)
==30714==    by 0x626DB4: bool boost::detail::lexical_stream_limited_src<char, std::char_traits<char>, true>::operator<< <boost::uuids::uuid>(boost::uuids::uuid const&) (lexical_cast.hpp:1431)
==30714==    by 0x6261EE: boost::detail::lexical_cast_do_cast<std::string, boost::uuids::uuid>::lexical_cast_impl(boost::uuids::uuid const&) (lexical_cast.hpp:1920)
==30714==    by 0x62590C: std::string boost::lexical_cast<std::string, boost::uuids::uuid>(boost::uuids::uuid const&) (lexical_cast.hpp:2087)
==30714==    by 0x624145: th::Object::Object(std::string const&) (Object.cpp:25)
t==30714== Conditional jump or move depends on uninitialised value(s)

What could it be?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T14:38:01+00:00Added an answer on June 1, 2026 at 2:38 pm

    boost::uuids::uuid is a POD type, so default-initializing a uuid object will in fact leave it uninitialized.

    Make sure you value-initialize your uuid object inside of your constructor’s initialization list:

    class MyType
    {
        std::string mName;
        boost::uuids::uuid mId;
    
    public:
        MyType()
          : mName(), // not technically necessary since std::string has a
                     // non-trivial default constructor, but good for consistency
            mId() // necessary in order to actually initialize mId, remains
                  // uninitialized otherwise
        {
            mName = boost::lexical_cast<std::string>(mId);
        }
    };
    

    Or better yet, by reordering your data member declarations:

    class MyType
    {
        boost::uuids::uuid mId;
        std::string mName;
    
    public:
        MyType()
          : mId(), // value-initialize mId
            mName(boost::lexical_cast<std::string>(mId)) // avoid unnecessary default
                                                         // construction of mName
        { }
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question about performance of move constructor, pseudo C++ class: typedef tuple<std::string,
I have a class which has two HashSet<String> collections as private members. Other classes
I have a static class with no static constructor, but many static members. I
I have class with member functions: typedef std::function<bool (const std::string &)> InsertFunction; bool insertSourceFile(
Suppose I have a class Foo with a std::string member str . What should
In my class I have a member: std::vector<std::string> memory_; Now I'd like to have
In my class I have two private members: std::list<MyObject> objects; MyObject *selecteObj; When an
I have this class that has many class members, and a lot of different
I have an organization class class Organization { hasMany = [member:Members] } class Members
I have a class that retrieves its memeber (more or less 10 members) from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.