C++14 partial ordering of function templates: MSVC 14 vs clang


As you might already know, MSVC 14 (Visual Studio 2015) is in its
testing phase currently. I stumbled upon a bug report that caught my
attention: https://connect.microsoft.com/VisualStudio/Feedback/Details/1114187

The author of this report complains that in the given example he
attached (http://pastebin.com/R5z88xcf) the call to function 'f'
should be unambiguous (MSVC 14 thinks otherwise) according to
paragraph 10 in the standard. In response, Visual C++ developer
Jonathan Caves argues that: "[] has been recently re-written
as the result of a defect report against the C++ language [...]
[...] So partial ordering fails and the function call is ambiguous."

Compiling the example in question (http://pastebin.com/R5z88xcf),
clang 3.5 and 3.6 think the call to f is unambiguous, MSVC14 thinks
it's ambiguous. My question is: which compiler is right about this? :slight_smile:



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.