Bug 55813 - Poorly named/documented option Wctor-dtor-privacy
Summary: Poorly named/documented option Wctor-dtor-privacy
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.2
: P3 normal
Target Milestone: 4.8.0
Assignee: Paolo Carlini
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-26 15:05 UTC by Harald van Dijk
Modified: 2016-06-09 21:11 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-02-27 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Harald van Dijk 2012-12-26 15:05:33 UTC
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.
Comment 1 Paolo Carlini 2013-02-27 18:43:25 UTC
Mine.
Comment 2 paolo@gcc.gnu.org 2013-02-28 10:01:04 UTC
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
Comment 3 Paolo Carlini 2013-02-28 10:03:03 UTC
Done.
Comment 4 Kyle J Strand 2016-05-31 19:29:22 UTC
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.
Comment 5 Manuel López-Ibáñez 2016-06-09 20:22:43 UTC
(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.
Comment 6 Kyle J Strand 2016-06-09 21:11:52 UTC
(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 .