public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/42608]  New: Undefined reference not reported in case of explicit template instantiation
@ 2010-01-04 13:58 bastien_emmanuel at yahoo dot fr
  2010-01-04 14:19 ` [Bug c++/42608] [4.4/4.5 Regression] " rguenth at gcc dot gnu dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: bastien_emmanuel at yahoo dot fr @ 2010-01-04 13:58 UTC (permalink / raw)
  To: gcc-bugs

The following code compiles without error and lead to a seg fault at runtime:

template <class U, class V>
struct A;

template <class V>
struct A<int, V> {
  void f();
};

template struct A<int, int>;

int main() {
  A<int, int> a;
  a.f();
  return 0;
}

Notice that there is no body defined for A<int, int>::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<int, int>::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


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2010-01-14 23:20 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-04 13:58 [Bug c++/42608] New: Undefined reference not reported in case of explicit template instantiation bastien_emmanuel at yahoo dot fr
2010-01-04 14:19 ` [Bug c++/42608] [4.4/4.5 Regression] " rguenth at gcc dot gnu dot org
2010-01-05 23:02 ` jason at gcc dot gnu dot org
2010-01-05 23:14 ` jason at gcc dot gnu dot org
2010-01-07 14:47 ` rguenth at gcc dot gnu dot org
2010-01-07 19:50 ` jason at gcc dot gnu dot org
2010-01-08 12:06 ` jakub at gcc dot gnu dot org
2010-01-08 13:42 ` jakub at gcc dot gnu dot org
2010-01-14 22:41 ` jakub at gcc dot gnu dot org
2010-01-14 22:47 ` jakub at gcc dot gnu dot org
2010-01-14 23:20 ` jakub at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).