From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7578 invoked by alias); 16 Jun 2013 02:59:10 -0000 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 Received: (qmail 7509 invoked by uid 48); 16 Jun 2013 02:59:02 -0000 From: "zeratul976 at hotmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/53184] Unnecessary anonymous namespace warnings Date: Sun, 16 Jun 2013 02:59: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-Version: 4.6.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: zeratul976 at hotmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-06/txt/msg00825.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53184 --- Comment #6 from Nathan Ridge --- (In reply to Jason Merrill from comment #4) > (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. Is this ODR violation an actual problem in practice, with GCC? I find these warnings annoying to work around, and I wouldn't mind seeing an option to silence them if they don't indicate an actual problem.