g++ and clang++ different behaviour with pointer to variadic template functions : <p>Another "who's right between g++ and clang++ ?" question for C++ standard gurus.</p>

<p>The code is the following</p>

<pre><code>template &lt;typename ...&gt;
struct bar
 { };

template &lt;typename ... Ts&gt;
void foo (bar&lt;Ts...&gt; const &amp;)
 { }

int main ()
 {
   foo&lt;int&gt;(bar&lt;int, long&gt;{});     // g++ and clang++ compile

   (*(&amp;foo&lt;int&gt;))(bar&lt;int, long&gt;{});  // g++ and clang++ give error

   (&amp;foo&lt;int&gt;)(bar&lt;int, long&gt;{});  // clang++ compiles; g++ gives error
 }
</code></pre>

<p>The template function <code>foo()</code> receive a variadic template parameter <code>bar</code>.</p>

<p>The first call </p>

<pre><code>   foo&lt;int&gt;(bar&lt;int, long&gt;{});     // g++ and clang++ compile
</code></pre>

<p>works for both clang++ ang g++.</p>

<p>If I understand correctly, with <code>foo&lt;int&gt;</code> is explicated <strong>only</strong> the first template parameter and this doesn't complete the list of <code>Ts...</code> parameters. So the compiler look at the argument (a <code>bar&lt;int, long&gt;</code> object) and deduce the full list.</p>

<p>The second call is different </p>

<pre><code>     (*(&amp;foo&lt;int&gt;))(bar&lt;int, long&gt;{});  // g++ and clang++ give error
</code></pre>

<p>If I understand correctly, with <code>(&amp;foo&lt;int&gt;)</code> we get the pointer to the instantiation of <code>foo</code> where <code>Ts...</code> is exactly <code>int</code> (not only the first type of the list but the whole list) and dereferencing it (<code>*(&amp;foo&lt;int&gt;)</code>) and calling it with a wrong argument (a <code>bar&lt;int, long&gt;</code> object) we get (clang++ and g++) a compilation error.</p>

<p>So far, so good.</p>

<p>The problem arises with the third call</p>

<pre><code>   (&amp;foo&lt;int&gt;)(bar&lt;int, long&gt;{});  // clang++ compiles; g++ gives error
</code></pre>

<p>that I was convinced (maybe I was wrong) equivalent the second one (we fix all template types in <code>Ts...</code>, then we call the function with a wrong parameter) but g++ seems agree (and gives error) where clang++ disagree (and compile without problem).</p>

<p>The question, as usual, is: who's right ?</p>
