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.
State-Changed-From-To: open->analyzed State-Changed-Why: Confirmed. A mainline regression
*** Bug 10994 has been marked as a duplicate of this bug. ***
*** Bug 11120 has been marked as a duplicate of this bug. ***
*** Bug 11367 has been marked as a duplicate of this bug. ***
Still happens on the mainline (20030715).
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.
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.
*** Bug 11872 has been marked as a duplicate of this bug. ***
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