This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/11872] New: missing template instantiation getting pointer to static members in inline member
- From: "monge at sns dot it" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 10 Aug 2003 02:56:47 -0000
- Subject: [Bug c++/11872] New: missing template instantiation getting pointer to static members in inline member
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11872
Summary: missing template instantiation getting pointer to static
members in inline member
Product: gcc
Version: 3.4
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: monge at sns dot it
CC: gcc-bugs at gcc dot gnu dot org
The following code fails to compile with linker error:
//**********************************************************
//tmpl.cpp
//**********************************************************
typedef void(*funx)();
template<class T> class ciao
{
public:
static void foo(){printf("ciao\n");}
void member() { funx f = foo; }
};
int main()
{
ciao<int> c;
c.member();
return 0;
}
//**********************************************************
I get
/tmp/ccaEJicr.o(.gnu.linkonce.t._ZN4ciaoIiE6memberEv+0x9): In function
`ciao<int>::member()':
: undefined reference to `ciao<int>::foo()'
in facts:
>g++ tmpl.cpp -c; nm -C tmpl.o
U ciao<int>::foo()
00000000 W ciao<int>::member()
00000000 T main
if i replace
void member() { funx f = foo; }
with
void member() { foo(); }
or
void member() { funx f = ciao::foo; }
or
void member() { funx f = ciao<int>::foo; }
(but not ciao<float>)
it works ok.
all work ok with g++ 2.95 and 3.2.
my config is:
Linux 2.4.20 (debian unstable)
libc 2.3.1
gcc:
Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.4/specs
Configured with: ./configure --with-gnu-as --with-gnu-ld --program-suffix=-3.4
--enable-languages=c,c++ --prefix=/usr
Thread model: posix
gcc version 3.4 20030723 (experimental)