This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/31187] New: [4.2 regression] extern declaration of variable in anonymous namespace prevents use of its address as template argument
- From: "zak at transversal dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 15 Mar 2007 14:25:29 -0000
- Subject: [Bug c++/31187] New: [4.2 regression] extern declaration of variable in anonymous namespace prevents use of its address as template argument
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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: '&<unnamed>::foo1' is not a valid template argument of type
'foo*' because '<unnamed>::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".
If I remove the line with the "extern" declaration, the code compiles again on
4.2.
--
Summary: [4.2 regression] extern declaration of variable in
anonymous namespace prevents use of its address as
template argument
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: zak at transversal dot com
GCC build triplet: x86_64-pc-linux-gnu
GCC host triplet: x86_64-pc-linux-gnu
GCC target triplet: x86_64-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31187