public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: llib@computer.org
To: gcc-gnats@gcc.gnu.org
Subject: c++/5086: -Wctor-dtor-privacy gives spurious warnings
Date: Tue, 11 Dec 2001 21:16:00 -0000	[thread overview]
Message-ID: <20011212050918.29032.qmail@sources.redhat.com> (raw)


>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==


             reply	other threads:[~2001-12-12  5:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-12-11 21:16 llib [this message]
2002-09-15 12:29 nathan
2003-05-08 22:24 bangerth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20011212050918.29032.qmail@sources.redhat.com \
    --to=llib@computer.org \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).