[LLVMbugs] [Bug 13032] New: improve overload resolution diagnostic for overloaded function argument

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Jun 5 14:22:42 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=13032

             Bug #: 13032
           Summary: improve overload resolution diagnostic for overloaded
                    function argument
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: quality-of-implementation
          Severity: enhancement
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: richard-llvm at metafoo.co.uk
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Consider this code:

#include <algorithm>

bool less(int, int);
bool less(const char*, const char*);

void f(int *arr, int size) {
  std::sort(arr, arr+size, less);
}

We produce this diagnostic:

<stdin>:7:3: error: no matching function for call to 'sort'
  std::sort(arr, arr+size, less);
  ^~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/4.4/../../../../include/c++/4.4/bits/stl_algo.h:5243:5:
note: candidate template ignored: couldn't infer template argument
      '_Compare'
    sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
    ^
/usr/lib/gcc/x86_64-linux-gnu/4.4/../../../../include/c++/4.4/bits/stl_algo.h:5207:5:
note: candidate function template not viable: requires 2 arguments, but 3
      were provided
    sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
    ^

It would be great if we could instead produce a diagnostic explaining that none
of the 'sort' overloads allowed us to resolve the overloaded 'less' function:

<stdin>:7:3: error: reference to overloaded function could not be resolved
  std::sort(arr, arr+size, less);
                           ^~~~
<stdin>:4:6: note: possible function
bool less(const char*, const char*);
     ^
<stdin>:3:6: note: possible function
bool less(int, int);
     ^

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list