[Bug c++/85856] New: -Weffc++ can't see implicitly deleted constructor
msharov at users dot sourceforge.net
gcc-bugzilla@gcc.gnu.org
Mon May 21 15:01:00 GMT 2018
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.
More information about the Gcc-bugs
mailing list