This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/38796] New: [c++0x] defaulted operator= with non-default return type accepted
- From: "reichelt at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 10 Jan 2009 17:16:32 -0000
- Subject: [Bug c++/38796] New: [c++0x] defaulted operator= with non-default return type accepted
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The following invalid code is accepted on the trunk:
========================================
struct A
{
void operator= (const A&) = default;
};
========================================
Because the return type is not "A&", but "void" the operator=
cannot be the defaulted.
In fact GCC silently changes the return type, as the following code
snippet is accepted:
========================================
struct A
{
void operator= (const A&) = default;
};
void foo()
{
A a, b, c;
a = b = c;
}
========================================
When I remove the default, I get a correct error message:
bug.cc: In function 'void foo()':
bug.cc:9: error: no match for 'operator=' in 'a = b.A::operator=(((const
A&)((const A*)(& c))))'
bug.cc:3: note: candidates are: void A::operator=(const A&)
This is probably related to PR38649.
--
Summary: [c++0x] defaulted operator= with non-default return type
accepted
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Keywords: accepts-invalid, monitored
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: reichelt at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38796