This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/45755] New: Member function template is instantiated to perform the copy
- From: "boostcpp at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Sep 2010 06:23:39 -0000
- Subject: [Bug c++/45755] New: Member function template is instantiated to perform the copy
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
"A member function template is never instantiated to perform the copy of a
class object to an object of its
class type."
But gcc instantiates it if function parameter type is the rvalue reference.
Following code shall not output anything if executed.
struct S
{
S() = default ;
template < typename T >
S( T && ) { std::cout << "bad constructor" << std::endl ; }
template < typename T >
S & operator = ( T && ){ std::cout << "bad assignment operator" <<
std::endl ; return *this ; }
} ;
int main()
{
S a ;
S b = a ; // must use trivial copy constructor
b = a ; // must use trivial assignment operator
}
But gcc instantiate and call bad constructor and assignment operator to perform
the copy.
--
Summary: Member function template is instantiated to perform the
copy
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: boostcpp at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45755