The -Wctor-dtor-privacy option is documented as `-Wctor-dtor-privacy (C++ only)' Warn when a class seems unusable, because all the constructors or destructors in a class are private and the class has no friends or public static member functions. However, the option warns for more than just that: class A { // warning: all member functions in class 'A' are private void f(); }; class B { // no warning void f() {} public: B() {} }; The documentation does not explain why a warning for A is issued, nor does it explain why A is treated differently from B. The option's name suggests that no warning should be generated for either of them, but I cannot tell what the actual intended behaviour is, only that gcc has behaved this way since before 3.x.
Mine.
Author: paolo Date: Thu Feb 28 10:00:54 2013 New Revision: 196334 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=196334 Log: 2013-02-28 Paolo Carlini <paolo.carlini@oracle.com> PR c++/55813 * doc/invoke.texi ([-Wctor-dtor-privacy]): Complete. Modified: trunk/gcc/ChangeLog trunk/gcc/doc/invoke.texi
Done.
The behavior (even as of 5.1) still seems at odds with the documentation. In particular, classes with *public* constructors *can* trigger this warning. See http://stackoverflow.com/q/33157248/1858225 for discussion and sample code.
(In reply to Kyle J Strand from comment #4) > See http://stackoverflow.com/q/33157248/1858225 for discussion and sample > code. The first testcase has a public static method. The second testcase seems like a bug, but this bug was about documentation. Please open a new PR and copy the testcase on it.
(In reply to Manuel López-Ibáñez from comment #5) > Please open a new PR and copy the testcase on it. Submitted as Bug 71484 .