[LLVMbugs] [Bug 14374] New: Local class can't access its members

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Nov 18 06:56:23 PST 2012


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

             Bug #: 14374
           Summary: Local class can't access its members
           Product: clang
           Version: 3.1
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: amanieu at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


$ cat a.cpp
#include <utility>
#include <functional>

template<typename Func>
std::function<void()> exec_func(Func&& f)
{
    struct functor {
        explicit functor(Func&& f): func(std::forward<Func>(f)) {}
        void operator()() const
        {
            func();
        }
        Func func;
    };
    return functor(std::forward<Func>(f));
}

int main()
{
    exec_func([]{});
}
$ clang++ -std=c++11 -c a.cpp
a.cpp:11:4: error: 'exec_func(<lambda at a.cpp:20:12>
&&)::functor::operator()()::functor::func' is not a member of class 'const
functor'
                        func();
                        ^
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../include/c++/4.7.2/functional:1925:2:
note: in instantiation of member function 'exec_func(<lambda at a.cpp:20:12>
&&)::functor::operator()' requested here
        (*_Base::_M_get_pointer(__functor))(
        ^
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../include/c++/4.7.2/functional:2297:33:
note: in instantiation of member function 'std::_Function_handler<void (),
functor>::_M_invoke' requested here
            _M_invoker = &_My_handler::_M_invoke;
                                       ^
a.cpp:15:9: note: in instantiation of function template specialization
'std::function<void ()>::function<functor>' requested here
        return functor(std::forward<Func>(f));
               ^
a.cpp:20:2: note: in instantiation of function template specialization
'exec_func<<lambda at a.cpp:20:12> >' requested here
        exec_func([]{});
        ^
1 error generated.

This was compiled using libstdc++ but the same error occurs with libc++.
Using this->func() instead of func() compiles fine.

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