[llvm-bugs] [Bug 39561] New: Super confusing diag when overload prevents template argument inference

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Nov 5 12:47:35 PST 2018


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

            Bug ID: 39561
           Summary: Super confusing diag when overload prevents template
                    argument inference
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: nicolasweber at gmx.de
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

Someone asked me why this doesn't build:

$ cat parallel_merge_sort.cpp 
#include <thread>
void mergesort(void *records, int start, int end, int threads) {
  std::thread lthread(mergesort, records, start, end, threads);
};


$ clang++ -std=c++11 -c parallel_merge_sort.cpp 
parallel_merge_sort.cpp:3:15: error: no matching constructor for initialization
of 'std::thread'
  std::thread lthread(mergesort, records, start, end, threads);
              ^       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/thread:353:9:
note: candidate template ignored: couldn't infer template argument '_Fp'
thread::thread(_Fp&& __f, _Args&&... __args)
        ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/thread:286:5:
note: candidate constructor not viable: requires 1 argument, but 5 were
provided
    thread(const thread&);
    ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/thread:309:5:
note: candidate constructor not viable: requires single argument '__t', but 5
arguments were provided
    thread(thread&& __t) _NOEXCEPT : __t_(__t.__t_) {__t.__t_ = 0;}
    ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/thread:293:5:
note: candidate constructor not viable: requires 0 arguments, but 5 were
provided
    thread() _NOEXCEPT : __t_(0) {}
    ^
1 error generated.


It builds fine on Windows, on Linux with libc++ and libstd++, but doesn't build
on macOS or on the BSDs.


The reason is that BSD has a function named "mergesort" in its C standard
library, which makes inference of the first thread ctor candidate fail. Our
diagnostic here could be much better.

-- 
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/20181105/db89a9cb/attachment.html>


More information about the llvm-bugs mailing list