cat > foo.cpp << EOF
class A {
public:
int x;
int getX() { return x; } // comment out to avoid warning
};
int foo() {
A a; // accepted: clearly the ctor is not private
return a.x;
}
EOF
g++ -c -Wctor-dtor-privacy foo.cpp
foo.cpp:1: warning: 'class A' only defines private constructors and has no
friends
This occurs in 4.0.0 and is a regression from 3.3.5 and 3.4.3.
--
Summary: spurious warning with -Wctor-dtor-privacy
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: bh at techhouse dot brown dot edu
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21347