public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/51609] New: [C++11] unique_ptr<const T[]>::reset rejects cv-compatible argument pointers
@ 2011-12-18 12:36 daniel.kruegler at googlemail dot com
  2011-12-18 15:06 ` [Bug libstdc++/51609] " redi at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2011-12-18 12:36 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 51609
           Summary: [C++11] unique_ptr<const T[]>::reset rejects
                    cv-compatible argument pointers
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: daniel.kruegler@googlemail.com


gcc 4.7.0 20111210 (experimental) in C++0x mode rejects the following code: 

//---------------
#include <memory>

struct T {};

T* bar() { return new T{}; }

int main()
{
  std::unique_ptr<const T[]> p;
  p.reset(bar()); // # Line 10
}
//---------------

"main.cpp||In function 'int main()':|
main.cpp|10|error: use of deleted function 'void std::unique_ptr<_Tp [],
_Dp>::reset(_Up) [with _Up = T*; _Tp = const T; _Dp = std::default_delete<const
T []>]'|
[..]include\c++\4.7.0\bits\unique_ptr.h|392|error: declared here|
"

This behaviour is in conflict with the standard. Referring to N3290
[unique.ptr.runtime] p1 b2:

"— Pointers to types derived from T are rejected by the constructors, and by
reset."

Further inspection of [unique.ptr.runtime.modifiers] does not reveal any
further constraints that could invalidate the assumption that reset should
accept the pointer to non-const T. This should also not be invalidated by the
constraints on default_delete<T[]>::operator(), because the deleter will always
be called on the internally hold pointer which has the correct type.

In regard to the seemingly difference to the constructor constraints of
[unique.ptr.runtime.ctor] p1 I would like to point to a new LWG issue:

http://cplusplus.github.com/LWG/lwg-active.html#2118


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

end of thread, other threads:[~2011-12-19 10:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-18 12:36 [Bug libstdc++/51609] New: [C++11] unique_ptr<const T[]>::reset rejects cv-compatible argument pointers daniel.kruegler at googlemail dot com
2011-12-18 15:06 ` [Bug libstdc++/51609] " redi at gcc dot gnu.org
2011-12-19  2:26 ` redi at gcc dot gnu.org
2011-12-19  7:13 ` daniel.kruegler at googlemail dot com
2011-12-19 10:43 ` 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).