[llvm-bugs] [Bug 44869] New: clang11 does not generate code for `shared_ptr_emplace`
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Feb 11 05:12:37 PST 2020
https://bugs.llvm.org/show_bug.cgi?id=44869
Bug ID: 44869
Summary: clang11 does not generate code for
`shared_ptr_emplace`
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++2a
Assignee: unassignedclangbugs at nondot.org
Reporter: vittorio.romeo at outlook.com
CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk
Created attachment 23119
--> https://bugs.llvm.org/attachment.cgi?id=23119&action=edit
Reproducible example
Description:
When creating a `std::shared_ptr` of a variadic template class inside a
coroutine, the compiler fails to generate the methods of the template class
`__shared_ptr_emplace`, and linking fails.
Links to reproducible example:
https://gcc.godbolt.org/z/GpqoYi
https://wandbox.org/permlink/NRmkf9cnb0eJHgqj
Resulting error:
/tmp/prog-e218f2.o:(.rodata._ZTVNSt3__120__shared_ptr_emplaceI1AIiENS_9allocatorIS2_EEEE[_ZTVNSt3__120__shared_ptr_emplaceI1AIiENS_9allocatorIS2_EEEE]+0x10):
undefined reference to `std::__1::__shared_ptr_emplace<A<int>,
std::__1::allocator<A<int> > >::~__shared_ptr_emplace()'
/tmp/prog-e218f2.o:(.rodata._ZTVNSt3__120__shared_ptr_emplaceI1AIiENS_9allocatorIS2_EEEE[_ZTVNSt3__120__shared_ptr_emplaceI1AIiENS_9allocatorIS2_EEEE]+0x18):
undefined reference to `std::__1::__shared_ptr_emplace<A<int>,
std::__1::allocator<A<int> > >::~__shared_ptr_emplace()'
/tmp/prog-e218f2.o:(.rodata._ZTVNSt3__120__shared_ptr_emplaceI1AIiENS_9allocatorIS2_EEEE[_ZTVNSt3__120__shared_ptr_emplaceI1AIiENS_9allocatorIS2_EEEE]+0x20):
undefined reference to `std::__1::__shared_ptr_emplace<A<int>,
std::__1::allocator<A<int> > >::__on_zero_shared()'
/tmp/prog-e218f2.o:(.rodata._ZTVNSt3__120__shared_ptr_emplaceI1AIiENS_9allocatorIS2_EEEE[_ZTVNSt3__120__shared_ptr_emplaceI1AIiENS_9allocatorIS2_EEEE]+0x30):
undefined reference to `std::__1::__shared_ptr_emplace<A<int>,
std::__1::allocator<A<int> > >::__on_zero_shared_weak()'
clang-11: error: linker command failed with exit code 1 (use -v to see
invocation)
How to reproduce:
Compile the code below with the following line:
/usr/bin/clang++-11 -std=gnu++2a -fcoroutines-ts -stdlib=libc++ -nostdinc++
-isystem/usr/lib/llvm-11/include/c++/v1/ -L/usr/lib/llvm-11/lib/
-Wl,-rpath,/usr/lib/llvm-11/lib test.cpp
Code:
#include <experimental/coroutine>
#include <tuple>
struct task
{
struct promise_type
{
task get_return_object() { return task{}; }
void return_void() {}
std::experimental::suspend_always initial_suspend() { return {}; }
void unhandled_exception() noexcept { std::terminate(); }
std::experimental::suspend_never final_suspend() { return {}; }
};
};
// removing the template fixes the linker error
template<typename Args>
struct A {};
int main()
{
// Using a regular function instead of a coroutine fixes the linker error
#ifdef FIX_1
auto coro = [](auto&& int2dbl) {
std::make_shared<A<int>>();
};
#else
auto coro = [](auto&& int2dbl) -> task {
std::make_shared<A<int>>();
co_return;
};
#endif
// Calling the coroutine directly fixes the linker error
#ifdef FIX_2
coro(A<int>());
#else
auto As = std::make_tuple(10);
std::apply([&](auto& wrapper) { return coro(wrapper); }, As);
#endif
}
--
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/20200211/2b28598d/attachment.html>
More information about the llvm-bugs
mailing list