title: gcc/linux: CppuTest shows memory leak using static vectors, false positive?
body: <p>in xxxx.h file:</p>
  
  <pre><code>struct dn_instance_pair
  {
      std::string theDn;
      int theInstance;
  };
  typedef struct dn_instance_pair t_dn_inst_pair;
  
  struct table_rowid_type
  {
      char theTable[101];
      sqlite3_int64 theRowid;
      int operation;
  };
  
  // static class members
  static vector&lt;t_dn_inst_pair&gt; dninstList;
  static vector&lt;t_table_rowid_type&gt; tablerowidList;
  </code></pre>
  
  <p>in xxxx.cpp</p>
  
  <pre><code>// declaration of vectors.
  // Included to this post only for completeness.
  vector&lt;t_dn_inst_pair&gt; xxxx::dninstList;
  vector&lt;t_table_rowid_type&gt; xxxx::tablerowidList;
  </code></pre>
  
  <p>These vectors are handled in static callback functions, so they must be static too.</p>
  
  <p>In cpputest, when trying to add something in either one of these vectors, a failure happens:</p>
  
  <pre><code>Leak size: 8 Allocated at: &lt;unknown&gt; and line: 0. Type: "new" Content: "&lt;\ufffdP@"
  </code></pre>
  
  <p>The stuff added to a vector are automatic variables and it happens in a normal function:</p>
  
  <pre><code>t_dn_inst_pair thePair;
  thePair.theDn = updated_dn;
  thePair.theInstance = updated_instance;
  </code></pre>
  
  <p>The vector is cleared in the end of the test case:</p>
  
  <pre><code>xxxx::yyyy()-&gt;dninstList.clear();
  </code></pre>
  
  <p>(yyyy() returns a pointer to a singleton xxxx object)</p>
  
  <p>Page <a href="http://blog.objectmentor.com/articles/2010/02/04/cpputest-recent-experiences" rel="noreferrer">http://blog.objectmentor.com/articles/2010/02/04/cpputest-recent-experiences</a>
  discusses the same kind of memory leak:</p>
  
  <blockquote>
    <p>"This is a false positive. This is a one-time allocation and a
    side-effect of C++ memory allocation and static initialization."</p>
  </blockquote>
  
  <p>So my question is:
  Is this failure genuinely a false positive ?</p>
  
  <p>br Esko</p>