title: Function returning std::string returns zero
body: <p>In maintaining a large legacy code base I came across this function which serves as an accessor to an XML tree.</p>
  
  <pre><code>std::string DvCfgNode::getStringValue() const
  {
      xmlChar *val = xmlNodeGetContent(mpNode);
      if (val == 0)
          return 0;
  
      std::string value = (const char *)val;
      xmlFree(val);
      return value;
  }
  </code></pre>
  
  <p>How can this function return '0'?  In C you could return a zero pointer as <code>char *</code> indicating no data was found, but is this possible in C++ with std::string?  I wouldn't think so but not knowledgable enough with C++.</p>
  
  <p>The (10 year old) code compiles and runs under C++ 98.</p>
  
  <p><strong>EDIT I</strong></p>
  
  <p>Thanks to everyone for the comments.  To answer a few questions:</p>
  
  <p>a) Code is actually 18 years old and about, umm, 500K-1M lines (?)</p>
  
  <p>b) exception handling <strong>is</strong> turned on, but there are no <code>try-catch</code> blocks anywhere except for a few in <code>main()</code>, which result in immediate program termination.</p>
  
  <p>c) Poor design in the calling code which seems to "trust" <code>getStringValue()</code> to return a proper value, so lots of something like:</p>
  
  <pre><code>std::string s = pTheNode-&gt;getStringValue()
  </code></pre>
  
  <p>Probably just lucky it never returned zero (or if it did, nobody found the bug until now).</p>