title: Did I find a bug in CppCheck? Why do I get the "Null pointer dereference" error here?
body: <p>I'm using Cppcheck to manage my code. I have the following function:</p>
  
  <pre><code>bool my_function(std::string my_string) const
  {
   return 0 == my_string.compare("Some text");  // line 3
  }
  </code></pre>
  
  <p>To my surprise, I get the <em>Null pointer dereference</em> in the line 3.</p>
  
  <p>I am completely confused: there are no pointers in my function. Why do I get this error?</p>
  
  <p>I've tried to investigate it: </p>
  
  <ol>
  <li><p>I checked if the string <em>my_string</em> is empty.</p></li>
  <li><p>I created an object using <em>"My text"</em> to make sure that Cppcheck doesn't complain about using a temporary object:</p>
  
  <pre><code>bool my_function(std::string my_string) const
  { 
   std::string str("Some text");
   return 0 == my_string.compare(str);  // line 3
  }
  </code></pre></li>
  </ol>
  
  <p>What else can I do? Is is a bug in Cppcheck? Is there a problem with the <em>compare</em> function itself? I'd be surprised if this was the case, since cppcheck doesn't complain about any other <em>std</em> functions that are used in my project.</p>
  
  <p>Note: I'm not asking about the <em>possible Null pointer dereference</em> error, so this is not a duplicate of any of the following questions: <a href="https://stackoverflow.com/questions/10312399/why-do-i-get-a-possible-null-pointer-dereference-warning">1</a>, <a href="https://stackoverflow.com/questions/4474357/c-possible-null-pointer-dereference">2</a> or <a href="https://stackoverflow.com/questions/29750481/cppcheck-possible-null-pointer-dereference">3</a>.</p>