This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/10804: regression from 3.2: implicit instantiation of template static methods
- From: harinath at cs dot umn dot edu
- To: gcc-gnats at gcc dot gnu dot org
- Cc: bsmedberg at covad dot net
- Date: 15 May 2003 16:31:49 -0000
- Subject: c++/10804: regression from 3.2: implicit instantiation of template static methods
- Reply-to: harinath at cs dot umn dot edu
>Number: 10804
>Category: c++
>Synopsis: regression from 3.2: implicit instantiation of template static methods
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu May 15 16:36:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: harinath@cs.umn.edu
>Release: gcc version 3.4 20030512 (experimental)
>Organization:
>Environment:
i686-pc-linux-gnu
>Description:
Linking fails on the following file:
--8<--
template<class T>
struct A
{
A() { const void (*a)() = foo; }
static const void foo() {}
};
int main(int argc, char *argv[])
{
A<int> a;
}
--8<--
with the error:
/tmp/ccube68X.o(.gnu.linkonce.t._ZN1AIiEC1Ev+0x9): In function `A<int>::A[in-charge]()':
: undefined reference to `A<int>::foo()'
collect2: ld returned 1 exit status
There is no problem with GCC 3.2.
>How-To-Repeat:
c++ implicit-instantiation.cc
Here's the output of nm with GCC 3.4:
U A<int>::foo()
00000000 W A<int>::A[in-charge]()
00000000 T main
and here's the output with GCC 3.2
00000000 W A<int>::foo()
00000000 W A<int>::A[in-charge]()
U __gxx_personality_v0
00000000 T main
Notice that GCC 3.4 did DTRT with the constructor. If I replace the use of foo in the code with a direct method call, then there's no problem either.
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/x-c++src; name="implicit-instantiation.cc"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="implicit-instantiation.cc"
dGVtcGxhdGU8Y2xhc3MgVD4Kc3RydWN0IEEKewogIEEoKSB7IGNvbnN0IHZvaWQgKCphKSgpID0g
Zm9vOyB9CiAgc3RhdGljIGNvbnN0IHZvaWQgZm9vKCkge30KfTsKCmludCBtYWluKGludCBhcmdj
LCBjaGFyICphcmd2W10pCnsKICBBPGludD4gYTsKfQo=