title: what's wrong with this anonymous constructor call?
body: <p>The following code compiles fine under GCC and MSVC:</p>
  <pre><code>#include &lt;string&gt;
  
  class C
  {
  public:
     C(const std::string&amp;) { }
  };
  
  void f()
  {
      std::string s;
      const std::string&amp; sr = s;
      C c = C(sr);
  }
  </code></pre>
  <p>Furthermore, if I replace that (entire) last line with this, both compilers accept it:</p>
  <p><code>(C(sr));</code></p>
  <p>However, if I replace that last line with this:</p>
  <p><code>C(sr);</code></p>
  <p>Compilers report the following:</p>
  <p>GCC:</p>
  <blockquote>
  <p>$ c++ --std=c++17 yo.cpp<br />
  yo.cpp: In function ‘void f()’:<br />
  yo.cpp:13:9: error: conflicting declaration ‘C sr’<br />
  C(sr);<br />
  ^<br />
  yo.cpp:12:24: note: previous declaration as ‘const string&amp; sr’<br />
  const std::string&amp; sr = s;</p>
  </blockquote>
  <p>MSVC:</p>
  <blockquote>
  <p>cl /std:c++17 Source.cpp<br />
  Microsoft (R) C/C++ Optimizing Compiler Version 19.16.27043 for x64<br />
  Copyright (C) Microsoft Corporation.  All rights reserved.<br />
  Source.cpp<br />
  C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\include\xlocale(319): warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc<br />
  Source.cpp(14): error C2040: 'sr': 'C' differs in levels of indirection from 'const std::string &amp;'<br />
  Source.cpp(14): error C2512: 'C': no appropriate default constructor available<br />
  Source.cpp(3): note: see declaration of 'C'</p>
  </blockquote>