[Bug libstdc++/58912] New: make_shared value initializes storage space even when not desired
cvs at cs dot utoronto.ca
gcc-bugzilla@gcc.gnu.org
Tue Oct 29 16:14:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58912
Bug ID: 58912
Summary: make_shared value initializes storage space even when
not desired
Product: gcc
Version: 4.8.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: cvs at cs dot utoronto.ca
Simple example:
struct foo {
char buf[1024*1024*1024];
foo() {}
};
auto p = std::make_shared<foo>();
I've traced the problem to shared_ptr_base.h and tested the following patch
(against 4.7.2) to resolve the problem:
--- shared_ptr_base.h.orig 2013-10-29 11:52:02.212301477 -0400
+++ shared_ptr_base.h 2013-10-29 11:52:20.620300707 -0400
@@ -394,7 +394,7 @@
public:
template<typename... _Args>
_Sp_counted_ptr_inplace(_Alloc __a, _Args&&... __args)
- : _M_impl(__a), _M_storage()
+ : _M_impl(__a)
{
_M_impl._M_ptr = static_cast<_Tp*>(static_cast<void*>(&_M_storage));
// _GLIBCXX_RESOLVE_LIB_DEFECTS
The problem appears to be in versions as new as 4.8.2.
Is there a good reason why the storage space must be initialized?
More information about the Gcc-bugs
mailing list