From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1965 invoked by alias); 2 May 2012 17:23:29 -0000 Received: (qmail 1954 invoked by uid 22791); 2 May 2012 17:23:28 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,KHOP_THREADED X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 02 May 2012 17:23:15 +0000 From: "jason at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/53184] Unnecessary anonymous namespace warnings Date: Wed, 02 May 2012 17:23:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jason at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-05/txt/msg00146.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53184 --- Comment #4 from Jason Merrill 2012-05-02 17:23:09 UTC --- (In reply to comment #3) > Because then the anonymous class has the name "Foo" for linkage purposes, and > has external linkage. When Foo referes to the const or volatile qualified form > of the class, the anonymous class itself has no name and so no linkage, only > the cv-qualified form has a name for linkage purposes. > > I'm not sure if that behaviour is correct though, let's ask Jason Yes, that's right. 7.1.3: If the typedef declaration defines an unnamed class (or enum), the first typedef-name declared by the declaration to be that class type (or enum type) is used to denote the class type (or enum type) for linkage purposes only (3.5). typedef struct { } *ps, S; // S is the class name for linkage purposes Adding volatile means that Foo doesn't name the class, it names the volatile variant of the class, so it isn't the class's name for linkage purposes, so the class has no linkage. The warning complains about using a type with no linkage as a member type in a header file, since including that header in multiple source files would be an ODR violation as the type Foo is different in each translation unit.