[Bug libstdc++/48398] New: [C++0x] std::unique_ptr<T, D> is broken when D::pointer is not T*
gintensubaru at gmail dot com
gcc-bugzilla@gcc.gnu.org
Fri Apr 1 08:30:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48398
Summary: [C++0x] std::unique_ptr<T, D> is broken when
D::pointer is not T*
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: gintensubaru@gmail.com
example:
------------------------------------------------------------
#include <memory>
#include <cassert>
struct my_deleter
{
typedef int* pointer;
void operator()( pointer p ) {
delete p;
}
};
int main()
{
std::unique_ptr<void, my_deleter> p( new int() );
assert( p.get() != 0 ); // invalid conversion from 'void*' to 'int*'
p.reset(); // no matching function for call to 'swap( void*&, int*& )'
}
------------------------------------------------------------
proposed patch:
--- libstdc++-v3/include/bits/unique_ptr.h
+++ libstdc++-v3/include/bits/unique_ptr.h
@@ -100,7 +100,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef decltype( __test<_Del>(0)) type;
};
- typedef std::tuple<_Tp*, _Dp> __tuple_type;
+ typedef std::tuple<typename _Pointer::type, _Dp> __tuple_type;
__tuple_type _M_t;
public:
More information about the Gcc-bugs
mailing list