Menu

performance warning - member variable at constructor

Marco
2017-05-17
2018-05-08
  • Marco

    Marco - 2017-05-17

    I get the perofrmance notification "Variable 'm_message' is assigned in constructor body. Consider performing initialization in initialization list." for the following code (the stringstream is little bit more complex in reality but I reduced the problem to this code):

    A::A(const std::string &message, int t) {
      std::stringstream ss;
      ss << t;
      m_message = ss.str();
    }
    

    But how can I solve this issue?

     
  • versat

    versat - 2018-05-08

    Did you get the performance notification for exactly the code you posted here too?
    I do not get any message for the code with the current development code.
    To me it looks like a false positive, i do not think that can be realized easily with initialization in the initialization list. Maybe it was a false positive that got fixed now.
    Can you verify it with a current version of Cppcheck?

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.