[llvm-bugs] [Bug 29036] New: Confusing error message when converting an overloaded function to std::function

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Aug 18 06:10:20 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=29036

            Bug ID: 29036
           Summary: Confusing error message when converting an overloaded
                    function to std::function
           Product: clang
           Version: 3.8
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++14
          Assignee: unassignedclangbugs at nondot.org
          Reporter: roman.perepelitsa at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Code:

#include <functional>

void F();
void F(int);

std::function<void()> f = F;

Error:

6: error: no viable conversion from '<overloaded function type>' to
'std::function<void ()>'
  std::function<void()> f = &F;
                        ^   ~~
[...]
functional:2192:7: note: candidate constructor not viable: no overload of 'F'
matching 'const std::function<void ()> &' for 1st argument
      function(const function& __x);
      ^
[...]

This statement is confusing: "no overload of 'F' matching 'const
std::function<void ()> &'". It's easy to misinterpret it as implying that the
compiler tried to convert every overload of 'F' to 'std::function<void ()>' and
failed.

-- 
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/20160818/dfcb928c/attachment-0001.html>


More information about the llvm-bugs mailing list