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
* [Bug libstdc++/51609] [C++11] unique_ptr<const T[]>::reset rejects cv-compatible argument pointers
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 ` redi at gcc dot gnu.org
2011-12-19 2:26 ` redi at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2011-12-18 15:06 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51609
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-12-18 14:47:50 UTC ---
I'll look into this today...
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libstdc++/51609] [C++11] unique_ptr<const T[]>::reset rejects cv-compatible argument pointers
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
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2011-12-19 2:26 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51609
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-12-19 02:24:24 UTC ---
While I agree the code is reasonable, I think an LWG issue is needed, because I
don't think GCC's behaviour is in conflict with the standard.
I don't read [unique.ptr.runtime] p1 b2 as requiring that cv-qualified types
must be accepted. It only says types derived from T are rejected, which GCC
does.
The standard defines exactly these overloads:
void reset(pointer p = pointer()) noexcept;
void reset(nullptr_t) noexcept;
template <class U> void reset(U) = delete;
and there is nothing in [unique.ptr.runtime.modifiers] to constrain the
template.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libstdc++/51609] [C++11] unique_ptr<const T[]>::reset rejects cv-compatible argument pointers
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
3 siblings, 0 replies; 5+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2011-12-19 7:13 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51609
--- Comment #3 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2011-12-19 07:07:52 UTC ---
(In reply to comment #2)
> While I agree the code is reasonable, I think an LWG issue is needed, because I
> don't think GCC's behaviour is in conflict with the standard.
I agree, my argumentation was solely based on the text and I overlooked the
difference in the signatures in the class synopsis. So, this issue should be
closed as invalid.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libstdc++/51609] [C++11] unique_ptr<const T[]>::reset rejects cv-compatible argument pointers
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
` (2 preceding siblings ...)
2011-12-19 7:13 ` daniel.kruegler at googlemail dot com
@ 2011-12-19 10:43 ` redi at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2011-12-19 10:43 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51609
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-12-19 10:26:57 UTC ---
OK, thanks, Daniel
^ 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).