[cfe-dev] C++14 partial ordering of function templates: MSVC 14 vs clang

Richard Smith richard at metafoo.co.uk
Tue Mar 3 13:51:57 PST 2015


On Tue, Mar 3, 2015 at 10:21 AM, Steven Watanabe <watanabesj at gmail.com>
wrote:

> AMDG
>
> On 03/03/2015 04:12 AM, Péter Ésik wrote:
> > Hello
> >
> > 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 14.8.2.4
> > paragraph 10 in the standard. In response, Visual C++ developer
> > Jonathan Caves argues that: "[14.8.2.4] has been recently re-written
> > as the result of a defect report against the C++ language [...]
> > http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1705
> > [...] 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? :)
> >
>
> The DR does not apply since type deduction only
> succeeds in one direction.


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150303/21364e4d/attachment.html>


More information about the cfe-dev mailing list