Bug 10804 - [3.4 regression] missing implicit instantiation of template static methods
Summary: [3.4 regression] missing implicit instantiation of template static methods
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P3 normal
Target Milestone: 3.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
: 10994 11120 11367 11872 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-05-15 16:36 UTC by Raja Harinath
Modified: 2004-01-17 04:22 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-07-27 22:32:17


Attachments
implicit-instantiation.cc (123 bytes, text/plain)
2003-05-21 15:17 UTC, Raja Harinath
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Raja Harinath 2003-05-15 16:36:00 UTC
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.

Release:
gcc version 3.4 20030512 (experimental)

Environment:
i686-pc-linux-gnu

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.
Comment 1 Wolfgang Bangerth 2003-05-15 18:36:26 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed. A mainline regression
Comment 2 Andrew Pinski 2003-05-28 14:05:55 UTC
*** Bug 10994 has been marked as a duplicate of this bug. ***
Comment 3 Wolfgang Bangerth 2003-06-07 00:38:32 UTC
*** Bug 11120 has been marked as a duplicate of this bug. ***
Comment 4 Wolfgang Bangerth 2003-06-30 14:49:48 UTC
*** Bug 11367 has been marked as a duplicate of this bug. ***
Comment 5 Andrew Pinski 2003-07-15 15:30:00 UTC
Still happens on the mainline (20030715).
Comment 6 Raja Harinath 2003-07-27 23:29:44 UTC
Appears to be fixed by Jan Hubicka's patch in

  http://gcc.gnu.org/ml/gcc-patches/2003-07/msg02584.html

for PR c++/11530.  That patch hasn't yet been reviewed/applied.
Comment 7 Andrew Pinski 2003-07-29 05:10:40 UTC
Fixed by:
2003-07-28  Mark Mitchell

        PR c++/11530
        * parser.c (cp_parser_postfix_expression): Do not call mark_used.
        * semantics.c (finish_id_expression): Call mark_used for all
        declarations.

Will submit a testcase soon.
Comment 8 Andrew Pinski 2003-08-10 03:00:40 UTC
*** Bug 11872 has been marked as a duplicate of this bug. ***
Comment 9 GCC Commits 2003-09-07 03:43:22 UTC
Subject: Bug 10804

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	pinskia@gcc.gnu.org	2003-09-07 03:43:15

Added files:
	gcc/testsuite/g++.dg/lookup: scoped7.C 
	gcc/testsuite/g++.dg/other: static1.C 
	gcc/testsuite/g++.dg/warn: template-1.C 
	gcc/testsuite/g++.dg/template: crash10.C call1.C 
	gcc/testsuite/g++.dg/overload: VLA.C 

Log message:
	2003-09-06  Andrew Pinski  <pinskia@physics.uc.edu>
	
	PR c++/11507
	* g++.dg/lookup/scoped7.C: New test.
	
	PR c++/9574
	* g++.dg/other/static1.C: New test.
	
	PR c++/11490
	* g++.dg/warn/template-1.C: New test.
	
	PR c++/11432
	* g++.dg/template/crash10.C: New test.
	
	PR c++/2478
	* g++.dg/overload/VLA.C: New test.
	
	PR c++/10804
	* g++.dg/template/call1.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/lookup/scoped7.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/other/static1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/template-1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/crash10.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/call1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/overload/VLA.C.diff?cvsroot=gcc&r1=NONE&r2=1.1