<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Mar 3, 2015 at 10:21 AM, Steven Watanabe <span dir="ltr"><<a href="mailto:watanabesj@gmail.com" target="_blank">watanabesj@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">AMDG<br>
<span class=""><br>
On 03/03/2015 04:12 AM, Péter Ésik wrote:<br>
> Hello<br>
><br>
> As you might already know, MSVC 14 (Visual Studio 2015) is in its<br>
> testing phase currently. I stumbled upon a bug report that caught my<br>
> attention: <a href="https://connect.microsoft.com/VisualStudio/Feedback/Details/1114187" target="_blank">https://connect.microsoft.com/VisualStudio/Feedback/Details/1114187</a><br>
><br>
> The author of this report complains that in the given example he<br>
> attached (<a href="http://pastebin.com/R5z88xcf" target="_blank">http://pastebin.com/R5z88xcf</a>) the call to function 'f'<br>
> should be unambiguous (MSVC 14 thinks otherwise) according to 14.8.2.4<br>
> paragraph 10 in the standard. In response, Visual C++ developer<br>
> Jonathan Caves argues that: "[14.8.2.4] has been recently re-written<br>
> as the result of a defect report against the C++ language [...]<br>
> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1705" target="_blank">http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1705</a><br>
> [...] So partial ordering fails and the function call is ambiguous."<br>
><br>
> Compiling the example in question (<a href="http://pastebin.com/R5z88xcf" target="_blank">http://pastebin.com/R5z88xcf</a>),<br>
> clang 3.5 and 3.6 think the call to f is unambiguous, MSVC14 thinks<br>
> it's ambiguous. My question is: which compiler is right about this? :)<br>
><br>
<br>
</span>The DR does not apply since type deduction only<br>
succeeds in one direction.</blockquote><div><br></div><div>That's not how it works; Jon Caves' explanation in the MS bug report is correct. Clang 3.6 did not implement DR1705; Clang SVN does (at least, partially), so we now report this case as being ambiguous. T& is better than T&&, const U& is better than U&, but A<V> is better than V, so the templates are not ordered and the call is ambiguous.</div></div></div></div>