title: Why does atomic_load with a shared_ptr not compile with gcc 4.9?
body: <p>This doesn't compile using gcc 4.9.3 (from the docker repo):</p>
  
  <pre><code>#include &lt;memory&gt;
  #include &lt;atomic&gt;
  
  int main() {
      auto p = std::make_shared&lt;int&gt;(3);
      auto n = std::atomic_load(&amp;p);
  }
  </code></pre>
  
  <p>To test with the gcc docker version (you can just copy-paste the whole block):</p>
  
  <pre><code>docker run -it gcc:4.9 bash
  # create a test.cpp with previous code:
  cat &gt; test.cpp &lt;&lt; EOF
  #include &lt;memory&gt;
  #include &lt;atomic&gt;
  
  int main() {
   auto p = std::make_shared&lt;int&gt;(3);
   auto n = std::atomic_load(&amp;p);
  }
  
  EOF
  # and compile:
  g++ -std=c++11 test.cpp -o bla
  </code></pre>
  
  <p>Fails to compile with 4.9, succeeds with 5.1, although <a href="https://gcc.gnu.org/projects/cxx0x.html" rel="nofollow" title="gcc C++0x/C++11 compatibility page">the C++0x/C++11 compatibility page</a> doesn't mention any troubles</p>
  
  <p>Just posting this here because I just lost several hours to figure out the problem, so no one else has to lose time on this :)</p>
  
  <p>Edit: add compiler output:</p>
  
  <pre><code>test.cpp: In function 'int main()':
  test.cpp:6:30: error: no matching function for call to 'atomic_load(std::shared_ptr&lt;int&gt;*)'
    auto n = std::atomic_load(&amp;p);
                                ^
  test.cpp:6:30: note: candidates are:
  In file included from test.cpp:2:0:
  /usr/local/include/c++/4.9.3/atomic:906:5: note: template&lt;class _ITp&gt; _ITp std::atomic_load(const std::atomic&lt;_ITp&gt;*)
       atomic_load(const atomic&lt;_ITp&gt;* __a) noexcept
       ^
  /usr/local/include/c++/4.9.3/atomic:906:5: note:   template argument deduction/substitution failed:
  test.cpp:6:30: note:   'std::shared_ptr&lt;int&gt;' is not derived from 'const std::atomic&lt;_ITp&gt;'
    auto n = std::atomic_load(&amp;p);
                                ^
  In file included from test.cpp:2:0:
  /usr/local/include/c++/4.9.3/atomic:911:5: note: template&lt;class _ITp&gt; _ITp std::atomic_load(const volatile std::atomic&lt;_ITp&gt;*)
       atomic_load(const volatile atomic&lt;_ITp&gt;* __a) noexcept
       ^
  /usr/local/include/c++/4.9.3/atomic:911:5: note:   template argument deduction/substitution failed:
  test.cpp:6:30: note:   'std::shared_ptr&lt;int&gt;' is not derived from 'const volatile std::atomic&lt;_ITp&gt;'
    auto n = std::atomic_load(&amp;p);
                                ^
  </code></pre>