From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14313 invoked by alias); 16 Mar 2007 15:15:27 -0000 Received: (qmail 14135 invoked by uid 22791); 16 Mar 2007 15:15:24 -0000 X-Spam-Check-By: sourceware.org Received: from postal.cs.tamu.edu (HELO postal.cs.tamu.edu) (128.194.138.100) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 16 Mar 2007 15:15:15 +0000 Received: from soliton.cs.tamu.edu (vpn-11.cs.tamu.edu [128.194.150.11]) by postal.cs.tamu.edu (Postfix) with ESMTP id F306746DE67; Fri, 16 Mar 2007 10:15:13 -0500 (CDT) Received: by soliton.cs.tamu.edu (Postfix, from userid 1000) id 017B81AAC9; Thu, 15 Mar 2007 11:11:10 -0500 (CDT) To: gcc-bugzilla@gcc.gnu.org Cc: gcc-bugs@gcc.gnu.org Subject: Re: [Bug c++/31187] New: [4.2 regression] extern declaration of variable in anonymous namespace prevents use of its address as template argument References: From: Gabriel Dos Reis In-Reply-To: Date: Fri, 16 Mar 2007 15:15:00 -0000 Message-ID: <87r6rqcwrm.fsf@soliton.cs.tamu.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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: 2007-03/txt/msg01550.txt.bz2 "zak at transversal dot com" writes: | The following code, which compiles fine on gcc 4.1.2 and I believe is valid, | fails on an up-to-date checkout from the 4.2 branch: | | -------------------------------------- | class foo { }; | | namespace | { | extern foo foo1; | foo foo1; | } | | template< foo * > | class bar { }; | | bar< &foo1 > bar1; | --------------------------------------- | | giving the error: | | test.cc:12: error: '&::foo1' is not a valid template argument of type | 'foo*' because '::foo1' does not have external linkage | test.cc:12: error: invalid type in declaration before ';' token | | | ... which I would only expect if "foo1" were declared "static". Yes, this is a bug in the compiler. I suspect it was introduced when the the back was told to treat declarations at unnamed namespaces ast static. That of course is an optimization and should be appear at the front-end. -- gaby