[Bug libstdc++/48398] [4.6/4.7 Regression] [C++0x] std::unique_ptr<T, D> is broken when D::pointer is not T*

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Apr 1 10:15:00 GMT 2011


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48398

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011.04.01 10:15:24
   Target Milestone|---                         |4.6.1
            Summary|[C++0x] std::unique_ptr<T,  |[4.6/4.7 Regression]
                   |D> is broken when           |[C++0x] std::unique_ptr<T,
                   |D::pointer is not T*        |D> is broken when
                   |                            |D::pointer is not T*
     Ever Confirmed|0                           |1

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-04-01 10:15:24 UTC ---
yes, the patch looks correct to me and should go on the 4.6 branch as it's a
regression caused by http://gcc.gnu.org/viewcvs?view=revision&revision=158682
when we started using deleter_type::pointer

Prior to that change this slight variation worked ok:

#include <memory>
#include <cassert>

struct my_deleter
{
  typedef int* pointer;

  void operator()( void* p ) {
    delete static_cast<pointer>(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*& )'
}


I won't be at home to test and commit it until tomorrow though



More information about the Gcc-bugs mailing list