public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/5086: -Wctor-dtor-privacy gives spurious warnings
@ 2001-12-11 21:16 llib
0 siblings, 0 replies; 3+ messages in thread
From: llib @ 2001-12-11 21:16 UTC (permalink / raw)
To: gcc-gnats
>Number: 5086
>Category: c++
>Synopsis: -Wctor-dtor-privacy gives spurious warnings
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Dec 11 21:16:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: Bill Clarke
>Release: 3.0.2
>Organization:
>Environment:
sparc-sun-solaris2.8
>Description:
the documentation for -Wctor-dtor-privacy says:
"`-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, -Wctor-dtor-privacy gives spurious warnings when the first public member function is not static. see the attached file (test-ctor-dtor-privacy.cc) in which the class ExhibitsCtorDtorPrivacyBug produces the "warning" but class DoesNotExhibitBug does not.
-Wctor-dtor-privacy is included in -Wall, and so is worth fixing (imo).
>How-To-Repeat:
compile attachment (test-ctor-dtor-privacy.cc, has no includes) with:
$ g++ -Wctor-dtor-privacy -c test-ctor-dtor-privacy.cc
test-ctor-dtor-privacy.cc:1: warning: `class ExhibitsCtorDtorPrivacyBug' only
defines private constructors and has no friends
$
>Fix:
the workaround is to put a static member function as the first public member.
an alternative fix is to change the documentation (-:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="test-ctor-dtor-privacy.cc"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="test-ctor-dtor-privacy.cc"
Y2xhc3MgRXhoaWJpdHNDdG9yRHRvclByaXZhY3lCdWcgewpwcml2YXRlOgogIEV4aGliaXRzQ3Rv
ckR0b3JQcml2YWN5QnVnKCk7CgogIC8vIGRpc2FsbG93IGNvcHk6CiAgRXhoaWJpdHNDdG9yRHRv
clByaXZhY3lCdWcoY29uc3QgRXhoaWJpdHNDdG9yRHRvclByaXZhY3lCdWcmKTsKICBFeGhpYml0
c0N0b3JEdG9yUHJpdmFjeUJ1ZyYgb3BlcmF0b3I9KGNvbnN0IEV4aGliaXRzQ3RvckR0b3JQcml2
YWN5QnVnJik7CnB1YmxpYzoKICB2b2lkIHRoaXNfY2F1c2VzX3RoZV9idWcoKTsKICBzdGF0aWMg
dm9pZCBkb19zb21ldGhpbmcoKTsKfTsKCmNsYXNzIERvZXNOb3RFeGhpYml0QnVnIHsKcHJpdmF0
ZToKICBEb2VzTm90RXhoaWJpdEJ1ZygpOwoKICAvLyBkaXNhbGxvdyBjb3B5OgogIERvZXNOb3RF
eGhpYml0QnVnKGNvbnN0IERvZXNOb3RFeGhpYml0QnVnJik7CiAgRG9lc05vdEV4aGliaXRCdWcm
IG9wZXJhdG9yPShjb25zdCBEb2VzTm90RXhoaWJpdEJ1ZyYpOwpwdWJsaWM6CiAgc3RhdGljIHZv
aWQgZG9fc29tZXRoaW5nKCk7CiAgdm9pZCB0aGlzX2lzX3RoZV93b3JrYXJvdW5kKCk7Cn07Cg==
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: c++/5086: -Wctor-dtor-privacy gives spurious warnings
@ 2003-05-08 22:24 bangerth
0 siblings, 0 replies; 3+ messages in thread
From: bangerth @ 2003-05-08 22:24 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, llib, nobody
Synopsis: -Wctor-dtor-privacy gives spurious warnings
State-Changed-From-To: analyzed->closed
State-Changed-By: bangerth
State-Changed-When: Thu May 8 22:24:06 2003
State-Changed-Why:
Fixed in 3.3 and mainline
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5086
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: c++/5086: -Wctor-dtor-privacy gives spurious warnings
@ 2002-09-15 12:29 nathan
0 siblings, 0 replies; 3+ messages in thread
From: nathan @ 2002-09-15 12:29 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, llib, nobody
Synopsis: -Wctor-dtor-privacy gives spurious warnings
State-Changed-From-To: open->analyzed
State-Changed-By: nathan
State-Changed-When: Sun Sep 15 12:29:48 2002
State-Changed-Why:
confirmed. (IMO, this is a pretty silly warning, the programmer wil find out very soon that everything's inaccessible.)
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5086
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-05-08 22:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-11 21:16 c++/5086: -Wctor-dtor-privacy gives spurious warnings llib
2002-09-15 12:29 nathan
2003-05-08 22:24 bangerth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).