[LLVMbugs] [Bug 22435] New: Partial ordering finds candidate to be more specialized despite contrary P/A pair

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Feb 2 10:35:37 PST 2015


            Bug ID: 22435
           Summary: Partial ordering finds candidate to be more
                    specialized despite contrary P/A pair
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: hstong at ca.ibm.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Clang does not produce a diagnostic (where GCC does) for the following where
the call in "bar" is expected to be ill-formed as per N4296 13.3.3/2; there is
no better function between (A) and (B), but Clang chooses (B).

### SOURCE (<stdin>):
template <typename T, typename U>
void foo(void (*)(T), const U &);  // (A)

template <typename T, typename U>
bool foo(void (*)(T &), U &);  // (B)

void bar(const int x) {
   bool b = foo<char>(0, x);

In particular, replacing the templates with their corresponding instantiations
as non-template functions, i.e.,

void foo(void (*)(char), const int &)
bool foo(void (*)(char &), const int &)

shows that Clang agrees that the call is ambiguous aside from template-related

Furthermore, the choice of (B) cannot be justified by bullet 1.7 in 13.3.3
since, following from, (B) is not more specialized than (A) due to
the following:

When the types of the second parameter are considered with (A) as the argument
template, bullet 9.2 in [temp.deduct.partial] applies and the
corresponding type from (B), the parameter template, is not considered to be at
least as specialized as the one from the argument template (A).

clang -cc1 -Wall -Wextra -Wno-unused -pedantic-errors -x c++ -

(Clean compile)

<stdin>:8:13: error: call to 'foo' is ambiguous
   bool b = foo<char>(0, x);
<stdin>:2:6: note: candidate function [with T = char, U = int]
void foo(void (*)(T), const U &);  // (A)
<stdin>:5:6: note: candidate function [with T = char, U = const int]
bool foo(void (*)(T &), U &);  // (B)
1 error generated.

clang version 3.7.0 (trunk 227802)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation:
Selected GCC installation:
Candidate multilib: .;@m64
Selected multilib: .;@m64

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150202/5d895426/attachment.html>

More information about the llvm-bugs mailing list