From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26570 invoked by alias); 4 Jan 2010 13:58:57 -0000 Received: (qmail 26535 invoked by uid 48); 4 Jan 2010 13:58:45 -0000 Date: Mon, 04 Jan 2010 13:58:00 -0000 Subject: [Bug c++/42608] New: Undefined reference not reported in case of explicit template instantiation X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "bastien_emmanuel at yahoo dot fr" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-01/txt/msg00376.txt.bz2 The following code compiles without error and lead to a seg fault at runtime: template struct A; template struct A { void f(); }; template struct A; int main() { A a; a.f(); return 0; } Notice that there is no body defined for A::f(). The correct link error is reported when no explicit template instantiation is requested: /tmp/ccycZSyE.o: In function `main': testcase.cpp:(.text+0x10): undefined reference to `A::f()' collect2: ld returned 1 exit status $g++ -v Using built-in specs. Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 4.4.2-7' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --with-arch-32=i486 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.4.2 (Debian 4.4.2-7) -- Summary: Undefined reference not reported in case of explicit template instantiation Product: gcc Version: 4.4.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: bastien_emmanuel at yahoo dot fr GCC build triplet: x86_64-linux-gnu GCC host triplet: x86_64-linux-gnu GCC target triplet: x86_64-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42608