Tested with Debian testing 4.4.3-3 and 4.3.4-8.
Compiling this code snippet:
template <int& field>
struct Foo
{
static int
bar ()
{ return field; }
};
template <bool>
struct X
{
static int x;
typedef Foo <x> foo;
};
// This makes first statement in main() compile, but not the second...
template <>
int X <false>::x = 0;
int
main ()
{
X <false>::x;
X <false>::foo::bar ();
}
with 'g++ test.cpp -o test' gives the following error on linking stage:
/tmp/ccuo8N2e.o: In function `_ZN3FooILZN1XIXT_EE1xEEE3barEv':
test.cpp:(.text._ZN3FooILZN1XIXT_EE1xEEE3barEv[_ZN3FooILZN1XIXT_EE1xEEE3barEv]+0x4):
undefined reference to `_ZN1XIXT_EE1xE'
This is a regression: it works with 4.1, but doesn't with 4.3 or 4.4. Didn't
test 4.2.
--
Summary: different access to templated structure static field
give different results
Product: gcc
Version: 4.4.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pogonyshev at gmx dot net
GCC build triplet: i486-pc-linux-gnu
GCC host triplet: i486-pc-linux-gnu
GCC target triplet: i486-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43368