title: How do I prevent trouble arising from std::string being constructed from `0`?
body: <pre><code>void foo (const std::string &amp;s) {}
  
  int main() {
    foo(0);   //compiles, but invariably causes runtime error
    return 0;
  }
  </code></pre>
  
  <p>The compiler (g++ 4.4) apparently interprets <code>0</code> as <code>char* NULL</code>, and constructs <code>s</code> by calling <code>string::string(const char*, const Allocator &amp;a = Allocator())</code>. Which is of course useless, because the <code>NULL</code> pointer is not a valid pointer to a c-string. This misinterpretation does not arise when I try to call <code>foo(1)</code>, this helpfully produces a compile-time error.</p>
  
  <p>Is there any possibility to get such an error or warning at compile-time when I accidentally call a function like</p>
  
  <pre><code>void bar(const std::string &amp;s, int i=1);
  </code></pre>
  
  <p>with <code>bar(0)</code>, forgetting about the <code>string</code>, and actually meaning to have <code>i=0</code>?</p>