From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2274 invoked by alias); 12 Dec 2001 05:16:05 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 2168 invoked by uid 71); 12 Dec 2001 05:16:02 -0000 Resent-Date: 12 Dec 2001 05:16:02 -0000 Resent-Message-ID: <20011212051602.2167.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, llib@computer.org Received:(qmail 29033 invoked by uid 61); 12 Dec 2001 05:09:18 -0000 Message-Id:<20011212050918.29032.qmail@sources.redhat.com> Date: Tue, 11 Dec 2001 21:16:00 -0000 From: llib@computer.org Reply-To: llib@computer.org To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version:gnatsweb-2.9.2 (1.1.1.1.2.21) Subject: c++/5086: -Wctor-dtor-privacy gives spurious warnings X-SW-Source: 2001-12/txt/msg00686.txt.bz2 List-Id: >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==