Skip to content

[Regression] std::function no longer accepts an incomplete return type. #33646

@hyp

Description

@hyp
Bugzilla Link 34298
Resolution FIXED
Resolved on Nov 22, 2017 06:45
Version 5.0
OS MacOS X
Blocks #33840
CC @DougGregor,@mclow,@zygoloid,@tstellar
Fixed by commit(s) r312892 r318835

Extended Description

The following code no longer compiles:

#include <functional>    

class Continuation
{
public:
        Continuation(const std::function<Continuation()>& next)
        : m_next(next) {}
        
        Continuation() {}
        
private:
	std::function<Continuation ()> m_next;
};

Because of the following error:

/Users/alex/bisect/b/include/c++/v1/type_traits:4323:23: error: calling 'operator()' with incomplete return type 'Continuation'
_LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/alex/bisect/b/include/c++/v1/__config:441:15: note: expanded from macro '_VSTD'
#define _VSTD std::_LIBCPP_NAMESPACE
              ^
/Users/alex/bisect/b/include/c++/v1/type_traits:4220:23: note: expanded from macro '_LIBCPP_INVOKE_RETURN'
    noexcept(noexcept(__VA_ARGS__)) -> decltype(__VA_ARGS__) \
                      ^~~~~~~~~~~
/Users/alex/bisect/b/include/c++/v1/type_traits:4340:9: note: in instantiation of exception specification for '__invoke<std::__1::function<Continuation ()> &>' requested here
        _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
        ^
/Users/alex/bisect/b/include/c++/v1/__config:441:15: note: expanded from macro '_VSTD'
#define _VSTD std::_LIBCPP_NAMESPACE
              ^
/Users/alex/bisect/b/include/c++/v1/functional:1601:33: note: in instantiation of template class 'std::__1::__invokable_r<void, std::__1::function<Continuation ()> &>' requested
      here
                                __invokable<_Fp&, _ArgTypes...>::value>
                                ^
/Users/alex/bisect/b/include/c++/v1/functional:1626:9: note: in instantiation of default argument for '__callable<std::__1::function<Continuation ()> >' required here
        __callable<_Fp>::value && !is_same<_Fp, function>::value
        ^~~~~~~~~~~~~~~
/Users/alex/bisect/b/include/c++/v1/functional:1628:5: note: in instantiation of default argument for 'function<std::__1::function<Continuation ()> >' required here
    function(_Fp);
    ^~~~~~~~~~~~~
/Users/alex/bisect/b/include/c++/v1/functional:1588:28: note: while substituting deduced template arguments into function template 'function' [with _Fp =
      std::__1::function<Continuation ()>, $1 = (no value)]
class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)>
                           ^
cxx.cpp:3:7: note: while declaring the implicit copy constructor for 'Continuation'
class Continuation
      ^
/Users/alex/bisect/b/include/c++/v1/functional:1680:9: note: 'operator()' declared here
    _Rp operator()(_ArgTypes...) const;
        ^
cxx.cpp:3:7: note: definition of 'Continuation' is not complete until the closing '}'
class Continuation
      ^
1 error generated.

I suspect libc++ for now, but it could be Clang itself.

libc++ r311156, LLVM r311438, Clang r311434

Metadata

Metadata

Assignees

Labels

bugzillaIssues migrated from bugzillalibc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions