public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/53654] New: move constructor incorrectly delete copy constructor defined by template
@ 2012-06-13 8:04 kirbyzhou@sogou-inc.com
2012-06-13 8:49 ` [Bug c++/53654] " redi at gcc dot gnu.org
2012-07-25 9:43 ` paolo.carlini at oracle dot com
0 siblings, 2 replies; 3+ messages in thread
From: kirbyzhou@sogou-inc.com @ 2012-06-13 8:04 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53654
Bug #: 53654
Summary: move constructor incorrectly delete copy constructor
defined by template
Classification: Unclassified
Product: gcc
Version: 4.7.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: kirbyzhou@sogou-inc.com
shared_ptr<T> declares its copy constructor and assign operator by template (if
Y == T). But the nontrivial copy constructor is been deleted by the move
constructor declaration.
////////////////////////////////////////////////////////
template<class T>
struct shared_ptr
{
template<class Y>
shared_ptr( shared_ptr<Y> const & r );
template<class Y>
shared_ptr& operator=( shared_ptr<Y> && r );
shared_ptr( shared_ptr<T> && r );
shared_ptr& operator=( shared_ptr<T> && r );
};
struct TTransport {
};
struct TProtocol {
shared_ptr<TTransport> func()
{
return p_;
}
shared_ptr<TTransport> p_;
};
////////////////////////////////////////////////////////
]# g++47 -std=gnu++0x -c tshareptr.cpp
tshareptr.cpp: In member function 'shared_ptr<TTransport> TProtocol::func()':
tshareptr.cpp:20:10: error: use of deleted function 'constexpr
shared_ptr<TTransport>::shared_ptr(const shared_ptr<TTransport>&)'
tshareptr.cpp:3:8: note: 'constexpr shared_ptr<TTransport>::shared_ptr(const
shared_ptr<TTransport>&)' is implicitly declared as deleted because
'shared_ptr<TTransport>' declares a move constructor or move assignment
operator
Workaround:
declare a separate copy constructor individually.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-07-25 9:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-13 8:04 [Bug c++/53654] New: move constructor incorrectly delete copy constructor defined by template kirbyzhou@sogou-inc.com
2012-06-13 8:49 ` [Bug c++/53654] " redi at gcc dot gnu.org
2012-07-25 9:43 ` paolo.carlini at oracle dot com
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).