This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/85856] New: -Weffc++ can't see implicitly deleted constructor
- From: "msharov at users dot sourceforge.net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 21 May 2018 15:00:31 +0000
- Subject: [Bug c++/85856] New: -Weffc++ can't see implicitly deleted constructor
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85856
Bug ID: 85856
Summary: -Weffc++ can't see implicitly deleted constructor
Product: gcc
Version: 8.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: msharov at users dot sourceforge.net
Target Milestone: ---
#include <stdio.h>
struct A {
A (void) {}
virtual ~A (void) {}
A (const A&) = delete;
void operator= (const A&) = delete;
};
struct B : public A {
B (const char* p) :A(),_p(p) {}
const char* _p;
};
int main (void)
{
B b ("hello");
puts (b._p);
return 0;
}
When compiling with -Weffc++ enabled, generates:
t.cc:10:8: warning: ‘struct B’ has pointer data members [-Weffc++]
struct B : public A {
^
t.cc:10:8: warning: but does not override ‘B(const B&)’ [-Weffc++]
t.cc:10:8: warning: or ‘operator=(const B&)’ [-Weffc++]
B already has an implicitly deleted copy constructor and operator= because A
implements them deleted. The compiler will correctly give a warning about it on
B b2=b, for example.