[LLVMbugs] [Bug 24137] New: std::make_shared will fail to compile for a const class with a default constructor
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Wed Jul 15 11:26:23 PDT 2015
https://llvm.org/bugs/show_bug.cgi?id=24137
Bug ID: 24137
Summary: std::make_shared will fail to compile for a const
class with a default constructor
Product: libc++
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: krasin at google.com
CC: llvmbugs at cs.uiuc.edu, mclow.lists at gmail.com
Classification: Unclassified
The following code will fail to compile:
#include <memory>
class Lala {
public:
Lala() = default;
//Lala() {}
virtual ~Lala() = default;
};
int main(void) {
const auto ptr = std::make_shared<const Lala>();
}
The error message is unsettling:
/usr/local/include/c++/v1/memory:2119:40: error: constructor for
'std::__1::__libcpp_compressed_pair_imp<std::__1::allocator<const Lala>, const
Lala, 1>' must explicitly initialize the const member '__second_'
_LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param
__t1)
^
/usr/local/include/c++/v1/memory:2389:11: note: in instantiation of member
function 'std::__1::__libcpp_compressed_pair_imp<std::__1::allocator<const
Lala>, const Lala, 1>::__libcpp_compressed_pair_imp' requested here
: base(_VSTD::forward<_T1_param>(__t1)) {}
^
/usr/local/include/c++/v1/memory:3771:12: note: in instantiation of member
function 'std::__1::__compressed_pair<std::__1::allocator<const Lala>, const
Lala>::__compressed_pair' requested here
: __data_(_VSTD::move(__a)) {}
^
/usr/local/include/c++/v1/memory:4366:26: note: in instantiation of member
function 'std::__1::__shared_ptr_emplace<const Lala, std::__1::allocator<const
Lala> >::__shared_ptr_emplace' requested here
::new(__hold2.get()) _CntrlBlk(__a2, _VSTD::forward<_Args>(__args)...);
^
/usr/local/include/c++/v1/memory:4730:29: note: in instantiation of function
template specialization 'std::__1::shared_ptr<const Lala>::make_shared<>'
requested here
return shared_ptr<_Tp>::make_shared(_VSTD::forward<_Args>(__args)...);
^
/home/krasin/make_shared.cc:11:25: note: in instantiation of function template
specialization 'std::__1::make_shared<const Lala>' requested here
const auto ptr = std::make_shared<const Lala>();
^
/usr/local/include/c++/v1/memory:2107:9: note: '__second_' declared here
_T2 __second_;
^
1 error generated.
I suspect this could be related to https://llvm.org/bugs/show_bug.cgi?id=21917,
but my feelings are that it's a different bug. Feel free to close this one, and
I will reopen 21917.
--
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/20150715/3abe1c5c/attachment.html>
More information about the llvm-bugs
mailing list