Odd behavior of different compilers with references to array of unknown bound
<p><strong>Case 1</strong></p>

<p>The following code produces drastically different results in MSVC and GCC:</p>

<pre><code>#include &lt;iostream&gt;

template &lt;typename T&gt;
void foo(const T&amp;) {
#ifdef _MSC_VER
    std::cout &lt;&lt; "foo(const T&amp;): " &lt;&lt; __FUNCDNAME__ &lt;&lt; std::endl;
#else
    std::cout &lt;&lt; __PRETTY_FUNCTION__ &lt;&lt; std::endl;
#endif
}

void foo(const char*) {
    std::cout &lt;&lt; "foo(const char*)" &lt;&lt; std::endl;
}

int main() {
    extern char s[];
    foo(s);
}

char s[] = "abc";
</code></pre>

<p>MSVC 2013 Update 5, MSVC 2015 Update 1 (also tried Update 2 on <a href="http://webcompiler.cloudapp.net" rel="nofollow">http://webcompiler.cloudapp.net</a> with the same result):</p>

<pre><code>foo(const char*)
</code></pre>

<p>GCC 5.3.0, Clang 3.7.0 (<a href="http://coliru.stacked-crooked.com/a/4f8cab913bb9a304" rel="nofollow">DEMO</a>):</p>

<pre><code>void foo(const T&amp;) [with T = char []]
</code></pre>

<p><strong>Case 2</strong></p>

<p>Now let's remove the templates:</p>

<pre><code>#include &lt;iostream&gt;

void foo(const char(&amp;)[]) {
    std::cout &lt;&lt; "foo(const char(&amp;)[])" &lt;&lt; std::endl;
}

void foo(const char*) {
    std::cout &lt;&lt; "foo(const char*)" &lt;&lt; std::endl;
}

int main() {
    extern char s[];
    foo(s);
}

char s[] = "abc";
</code></pre>

<p>MSVC produces error:</p>

<pre><code>error C2668: 'foo' : ambiguous call to overloaded function
could be 'void foo(const char *)'
or       'void foo(const char (&amp;)[])'
</code></pre>

<p>GCC produces another error (with both <code>-std=c++14</code> and <code>-std=c++1z</code>):</p>

<pre><code>main.cpp:3:29: error: parameter '&lt;anonymous&gt;' includes reference to array of unknown bound 'const char []'
     void foo(const char(&amp;)[]) {
</code></pre>

<p>And Clang compiles with both <code>-std=c++14</code> and <code>-std=c++1z</code> and outputs:</p>

<pre><code>foo(const char(&amp;)[])
</code></pre>

<hr>

<p>For the first case, in my opininon with C++14 the specialization <code>void foo(const T&amp;) [with T = char []]</code> shouldn't have been produced in the first place, so MSVC is right. But in C++1z GCC and Clang are right.</p>

<p>For the second case, I think with C++14 GCC is right and with C++1z Clang is right.</p>

<p>(The important difference between C++14 and C++1z here is <a href="http://www.open-std.org/JTC1/SC22/WG21/docs/cwg_defects.html#393" rel="nofollow">CWG 393</a>)</p>

<hr>

<p>So the questions are, which compiler is right in the first and the second cases in C++14 (N4140) and C++1z (N4567)?</p>

<p>And another question, which compiler(s), if any, should I file a bug for?</p>