This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/11872] New: missing template instantiation getting pointer to static members in inline member


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)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]