title: Is it allowed to name a global variable `read` or `malloc` in C++?
body: <p>Consider the following C++17 code:</p>
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt;
  int read;
  int main(){
      std::ios_base::sync_with_stdio(false);
      std::cin &gt;&gt; read;
  }
  </code></pre>
  <p>It compiles and runs fine on <a href="https://godbolt.org/z/asKsv95G5" rel="noreferrer">Godbolt</a> with GCC 11.2 and Clang 12.0.1, but results in runtime error if compiled with a <code>-static</code> key.</p>
  <p>As far as I understand, there is a POSIX(?) function called <code>read</code> (see <a href="https://man7.org/linux/man-pages/man2/read.2.html" rel="noreferrer"><code>man read(2)</code></a>), so the example above actually invokes ODR violation and the program is essentially ill-formed even when compiled without <code>-static</code>. GCC even emits warning if I try to name a variable <code>malloc</code>: <code>built-in function 'malloc' declared as non-function</code></p>
  <p>Is the program above valid C++17? If no, why? If yes, is it a compiler bug which prevents it from running?</p>