[llvm-bugs] [Bug 46678] New: LIBCXX_ABI_OPTIMIZED_FUNCTION: Incomplete return type in template argument for std::function fails to compile
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Jul 10 16:48:02 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=46678
Bug ID: 46678
Summary: LIBCXX_ABI_OPTIMIZED_FUNCTION: Incomplete return type
in template argument for std::function fails to
compile
Product: libc++
Version: 10.0
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: dschuff at google.com
CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com
When using the optimized std::function ABI (LIBCXX_ABI_OPTIMIZED_FUNCTION)
and compiling the following:
#include <iostream>
#include <functional>
struct foo;
using fnc = std::function<foo(int)>;
struct bar {
bar() {
std::cout << "construct me" << std::endl;
}
fnc _f{nullptr};
};
int main(int argc, const char * argv[]) {
// insert code here...
std::cout << "Hello, World!\n";
bar b{};
return 0;
}
you get an error:
In file included from test.cc:1:
In file included from
/Users/dschuff/code/emr/emscripten-releases/emscripten/system/include/libcxx/iostream:37:
In file included from
/Users/dschuff/code/emr/emscripten-releases/emscripten/system/include/libcxx/ios:215:
In file included from
/Users/dschuff/code/emr/emscripten-releases/emscripten/system/include/libcxx/__locale:14:
In file included from
/Users/dschuff/code/emr/emscripten-releases/emscripten/system/include/libcxx/string:504:
In file included from
/Users/dschuff/code/emr/emscripten-releases/emscripten/system/include/libcxx/string_view:175:
In file included from
/Users/dschuff/code/emr/emscripten-releases/emscripten/system/include/libcxx/__string:56:
In file included from
/Users/dschuff/code/emr/emscripten-releases/emscripten/system/include/libcxx/algorithm:644:
/Users/dschuff/code/emr/emscripten-releases/emscripten/system/include/libcxx/functional:2051:16:
error: incomplete result type 'foo' in function definition
static _Rp __call_empty(const __policy_storage*,
^
/Users/dschuff/code/emr/emscripten-releases/emscripten/system/include/libcxx/functional:2038:35:
note: in instantiation of member function
'std::__2::__function::__policy_invoker<foo (int)>::__call_empty' requested
here
__policy_invoker() : __call_(&__call_empty) {}
^
/Users/dschuff/code/emr/emscripten-releases/emscripten/system/include/libcxx/functional:2090:5:
note: in instantiation of member function
'std::__2::__function::__policy_invoker<foo (int)>::__policy_invoker' requested
here
__policy_func() : __policy_(__policy::__create_empty()) {}
^
/Users/dschuff/code/emr/emscripten-releases/emscripten/system/include/libcxx/functional:2276:5:
note: in instantiation of member function
'std::__2::__function::__policy_func<foo (int)>::__policy_func' requested here
function(nullptr_t) _NOEXCEPT {}
^
test.cc:9:11: note: in instantiation of member function 'std::__2::function<foo
(int)>::function' requested here
fnc _f{nullptr};
^
test.cc:3:8: note: forward declaration of 'foo'
struct foo;
^
1 error generated.
(this example uses emscripten, which currently uses libc++ 10.0 with some ABIv2
enabled)
If you instead use a complete type:
using fnc = std::function<void (int, foo&)>;
then it will compile.
On other platforms (and in libc++ using the stable std::function ABI) it also
works.
--
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/20200710/26c6accb/attachment-0001.html>
More information about the llvm-bugs
mailing list