title: Using decltype(auto) in C++ non-type template parameter
body: <p>I am learning C++17 new feature <code>decltype(auto)</code> for non-type template parameter. I wrote a simple code snippet as following:</p>
  <pre><code>#include &lt;type_traits&gt;
  
  template&lt;decltype(auto) arg&gt;
  struct Foo {};
  
  int
  main()
  {
      constexpr int x = 42;
      static_assert(std::is_same_v&lt;Foo&lt;42&gt;, Foo&lt;x&gt;&gt;);
  }
  </code></pre>
  <p>As I understand, <code>Foo&lt;42&gt;</code> should be the same type as <code>Foo&lt;x&gt;</code>.</p>
  <p>However, The <code>static_assert</code> statement compiles with clang++, MSVC 19.27 but fails with GCC 10.2, MSVC 19.25.</p>
  <p>My question is: Why do compilers behave differently? What does the Standard say about this?</p>
  <p>Link to Compiler Explorer:</p>
  <p>clang++ <a href="https://godbolt.org/z/66M695" rel="noreferrer">https://godbolt.org/z/66M695</a></p>
  <p>gcc <a href="https://godbolt.org/z/3v5Mhd" rel="noreferrer">https://godbolt.org/z/3v5Mhd</a></p>
  <p>MSVC 19.25 <a href="https://godbolt.org/z/qP6v89" rel="noreferrer">https://godbolt.org/z/qP6v89</a></p>
  <p>MSVC 19.27 <a href="https://godbolt.org/z/14aK5Y" rel="noreferrer">https://godbolt.org/z/14aK5Y</a></p>