[LLVMbugs] [Bug 7202] New: Boost thread ambiguity when used in a template function, with operator new

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat May 22 12:38:50 PDT 2010


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

           Summary: Boost thread ambiguity when used in a template
                    function, with operator new
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: tronic+hfu3 at trn.iki.fi
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


$ cat testi.cc
#include <boost/thread.hpp>

struct Foo {
    template <typename T> Foo(T) {
        new boost::thread(boost::ref(*this));
    }
    void operator()() {}
};

int main() {
    Foo foo(1);
}

$ clang++ testi.cc -lboost_thread-mt
testi.cc:5:3: error: call to constructor of 'boost::thread' is ambiguous
                new boost::thread(boost::ref(*this));
                ^
testi.cc:11:6: note: in instantiation of function template specialization
'Foo::Foo<int>' requested here
        Foo foo(1);
            ^
In file included from testi.cc:1:
In file included from /usr/include/boost/thread.hpp:13:
In file included from /usr/include/boost/thread/thread.hpp:22:
/usr/include/boost/thread/detail/thread.hpp:185:18: note: candidate constructor
[with F = boost::reference_wrapper<Foo>]
        explicit thread(F f,typename
disable_if<boost::is_convertible<F&,detail::thread_move_t<F> >, dummy*
>::type=0):
                 ^
/usr/include/boost/thread/detail/thread.hpp:226:9: note: candidate constructor
[with F = boost::reference_wrapper<Foo>, A1 = boost::thread::dummy *]
        thread(F f,A1 a1):
        ^
1 error generated.

Make Foo::Foo non-template or remove the new in front of boost::thread and the
program builds fine.

Workaround: new boost::thread(&Foo::operator(), this)

-- 
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