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

* [Bug libstdc++/48398] [C++0x] std::unique_ptr<T, D> is broken when D::pointer is not T*
  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 ` 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
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-04-01  9:25 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jwakely.gcc at gmail dot
                   |                            |com

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-04-01 09:24:53 UTC ---
Thanks.

Jon, both PR and patch seem straightforward to me, I would go ahead for
mainline and 4_6-branch too. Just let me know if you have the time...


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

* [Bug libstdc++/48398] [4.6/4.7 Regression] [C++0x] std::unique_ptr<T, D> is broken when D::pointer is not T*
  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 ` redi at gcc dot gnu.org
  2011-04-01 10:22 ` paolo.carlini at oracle dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2011-04-01 10:15 UTC (permalink / raw)
  To: gcc-bugs

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


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

* [Bug libstdc++/48398] [4.6/4.7 Regression] [C++0x] std::unique_ptr<T, D> is broken when D::pointer is not T*
  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
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-04-01 10:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-04-01 10:21:59 UTC ---
Ah, ok, thanks then!


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

* [Bug libstdc++/48398] [4.6/4.7 Regression] [C++0x] std::unique_ptr<T, D> is broken when D::pointer is not T*
  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
                   ` (2 preceding siblings ...)
  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
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2011-04-02 15:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-04-02 15:34:05 UTC ---
Author: redi
Date: Sat Apr  2 15:34:01 2011
New Revision: 171889

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=171889
Log:
2011-04-02  Jonathan Wakely  <redi@gcc.gnu.org>

    PR libstdc++/48398
    * include/bits/unique_ptr.h (__tuple_type): Store pointer type.
    * testsuite/20_util/unique_ptr/modifiers/48398.cc: New.
    * testsuite/20_util/unique_ptr/requirements/pointer_type.cc: Remove
    unused parameter name.

Added:
   
branches/gcc-4_6-branch/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/48398.cc
Modified:
    branches/gcc-4_6-branch/libstdc++-v3/ChangeLog
    branches/gcc-4_6-branch/libstdc++-v3/include/bits/unique_ptr.h
   
branches/gcc-4_6-branch/libstdc++-v3/testsuite/20_util/unique_ptr/requirements/pointer_type.cc


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

* [Bug libstdc++/48398] [4.6/4.7 Regression] [C++0x] std::unique_ptr<T, D> is broken when D::pointer is not T*
  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
                   ` (3 preceding siblings ...)
  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
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2011-04-02 19:32 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-04-02 19:32:18 UTC ---
Author: redi
Date: Sat Apr  2 19:32:15 2011
New Revision: 171894

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=171894
Log:
2011-04-02  Jonathan Wakely  <redi@gcc.gnu.org>

    PR libstdc++/48398
    * include/bits/unique_ptr.h (__tuple_type): Store pointer type.
    * testsuite/20_util/unique_ptr/modifiers/48398.cc: New.
    * testsuite/20_util/unique_ptr/requirements/pointer_type.cc: Remove
    unused parameter name.

Added:
    trunk/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/48398.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/bits/unique_ptr.h
   
trunk/libstdc++-v3/testsuite/20_util/unique_ptr/requirements/pointer_type.cc


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

* [Bug libstdc++/48398] [4.6/4.7 Regression] [C++0x] std::unique_ptr<T, D> is broken when D::pointer is not T*
  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
                   ` (4 preceding siblings ...)
  2011-04-02 19:32 ` redi at gcc dot gnu.org
@ 2011-04-02 19:35 ` redi at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2011-04-02 19:35 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-04-02 19:35:13 UTC ---
fixed for 4.6.1 - thanks for the report


^ 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).