title: Weird behavior with a manually defined strlen
body: <p>Accidentally, I wrote the following interesting snippet:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstring&gt;
  
  size_t strlen(const char* str) {
      std::cout &lt;&lt; "hello";
      return 0;
  }
  
  int main() {
      return std::strlen("sdf");
  }
  </code></pre>
  
  <p>Unexpectedly for me, the output is "hello" in GCC 5.1, which means that my <code>strlen</code> is being called. Even more interesting, if I remove the <code>return</code>, i.e. replace main with just a call of <code>std::strlen("sdf");</code>, nothing gets printed!</p>
  
  <p>I also tried Clang, for which <code>std::strlen</code> calls the real function which calculates the string length (and nothing gets printed). That's what I expected to see.</p>
  
  <p>How can this be explained? Is defining my own <code>strlen</code> function considered undefined behavior?</p>