title: Why does <cmath> expose entities outside the std namespace?
body: <p>As far as I understand it C-entities used by C++ like those in <code>&lt;math.h&gt;</code> can be included in a safe way inside an <code>std</code> namespace by including their corresponding <code>&lt;c...&gt;</code> variant (except macros, obviously). <a href="https://en.cppreference.com/mwiki/index.php?title=Special%3ASearch&amp;search=log" rel="nofollow noreferrer">cppreference seems to confirm this</a>.</p>
  
  <p>However, including <code>&lt;cmath&gt;</code> appears to pull in the <code>log</code> function <em>outside</em> the <code>std</code> namespace:</p>
  
  <pre><code>#include &lt;cmath&gt;
  
  namespace log {}
  
  int main() {}
  </code></pre>
  
  <p>Compiled with <code>g++ -Wall -Wextra -pedantic -std=c++17 a.cpp</code> yields:</p>
  
  <pre><code>a.cpp:3:11: error: ‘namespace log { }’ redeclared as different kind of entity
      3 | namespace log {}
        |           ^~~
  In file included from /usr/include/features.h:446,
                   from /usr/include/x86_64-linux-gnu/c++/9/bits/os_defines.h:39,
                   from /usr/include/x86_64-linux-gnu/c++/9/bits/c++config.h:524,
                   from /usr/include/c++/9/cmath:41,
                   from a.cpp:1:
  /usr/include/x86_64-linux-gnu/bits/mathcalls.h:104:1: note: previous declaration ‘double log(double)’
    104 | __MATHCALL_VEC (log,, (_Mdouble_ __x));
        | ^~~~~~~~~~~~~~
  </code></pre>
  
  <p><strong>Is my standard library broken? Can I do something to avoid this?</strong></p>
  
  <hr>
  
  <p>I originally stumbled over this using <code>&lt;random&gt;</code>, which means that more headers might be affected by apparently random C-entities being spewed all across the top level namespace.</p>