public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/48398] New: [C++0x] std::unique_ptr<T, D> is broken when D::pointer is not T*
@ 2011-04-01  8:30 gintensubaru at gmail dot com
  2011-04-01  9:25 ` [Bug libstdc++/48398] " paolo.carlini at oracle dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: gintensubaru at gmail dot com @ 2011-04-01  8:30 UTC (permalink / raw)
  To: gcc-bugs

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:


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-04-02 19:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-01  8:30 [Bug libstdc++/48398] New: [C++0x] std::unique_ptr<T, D> is broken when D::pointer is not T* gintensubaru at gmail dot com
2011-04-01  9:25 ` [Bug libstdc++/48398] " paolo.carlini at oracle dot com
2011-04-01 10:15 ` [Bug libstdc++/48398] [4.6/4.7 Regression] " redi at gcc dot gnu.org
2011-04-01 10:22 ` paolo.carlini at oracle dot com
2011-04-02 15:34 ` redi at gcc dot gnu.org
2011-04-02 19:32 ` redi at gcc dot gnu.org
2011-04-02 19:35 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).