gcc bug? It inexplicably decays array to pointer, while clang does not : <p>This is a simplified version which illustrate the problem:</p>

<pre><code>struct Foo {
    Foo() = default;

    template &lt;std::size_t N&gt;
    Foo(const char(&amp;)[N]) {}
};

template &lt;std::size_t N&gt;
auto foo(const char (&amp;arr)[N]) -&gt; Foo
{
    return arr;
}

auto main() -&gt; int
{
    foo("Stack Overflow");
}
</code></pre>

<p>g++ seems to decay <code>arr</code> to <code>const char *</code>, although an array reference argument is passed to an array reference parameter . It gives this error:</p>

<blockquote>
  <p>In instantiation of <code>Foo foo(const char (&amp;)[N]) [with long unsigned
  int N = 4ul]</code>:</p>
  
  <p>error: could not convert <code>(const char*)arr</code> from <code>const char*</code> to
  <code>Foo</code></p>

<pre><code> return arr;
        ^
</code></pre>
</blockquote>

<p>While clang++ behaves how I expect and compiles the code.</p>

<p>The code compiles fine on gcc with any of those modifications:</p>

<pre><code>return {arr};
return Foo(arr);
return (Foo)arr;
return static_cast&lt;Foo&gt;(arr);
</code></pre>

<p>Is it a gcc bug?</p>

<p>Tried it with <del>all</del> g++ and clang++ versions which support <code>c++14</code>.(*)</p>

<p>(*) I just tried it with a snapshot of <code>gcc 6</code> and it compiles OK. So it does look like a bug fixed in <code>gcc 6</code></p>
