public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/51629] New: Default Destructor and template extern Instantiation cause the Destructor to be missing
@ 2011-12-20  0:12 m_v_ at gmx dot net
  2011-12-20  0:13 ` [Bug c++/51629] " m_v_ at gmx dot net
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: m_v_ at gmx dot net @ 2011-12-20  0:12 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51629

             Bug #: 51629
           Summary: Default Destructor and template extern Instantiation
                    cause the Destructor to be missing
    Classification: Unclassified
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: m_v_@gmx.net


Created attachment 26148
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26148
Reproduction code, archive since i need a seperate compilation unit for extern
template instantiation

If I compile a templated class A with the destructor "~A() = default;" it works
fine. However if I try to use "extern template class A<type>", and instantiate
the code in another compilation unit it fails.
It works fine if either of the marked lines "~A() = default" or the private
variable with a typedefed type are removed.

Comandline used
===============
g++ main.cpp instant.cpp -o main -std=c++0x


Error Message
=============
/tmp/cc09sFi6.o: In function `main':
main.cpp:(.text+0x2b): undefined reference to
`eventManager_base<void>::~eventManager_base()'
collect2: ld returned 1 exit status


g++ -v output:
==============
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6.1/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro
4.6.1-9ubuntu3' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr
--program-suffix=-4.6 --enable-shared --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin
--enable-objc-gc --disable-werror --with-arch-32=i686 --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.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3)


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

* [Bug c++/51629] Default Destructor and template extern Instantiation cause the Destructor to be missing
  2011-12-20  0:12 [Bug c++/51629] New: Default Destructor and template extern Instantiation cause the Destructor to be missing m_v_ at gmx dot net
@ 2011-12-20  0:13 ` m_v_ at gmx dot net
  2011-12-20  6:28 ` paolo.carlini at oracle dot com
  2013-09-03 15:53 ` rob.desbois at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: m_v_ at gmx dot net @ 2011-12-20  0:13 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51629

--- Comment #1 from ted <m_v_ at gmx dot net> 2011-12-20 00:12:59 UTC ---
Link to topic on stack oveflow with discussion/detection, thanks to deft_code:
http://stackoverflow.com/questions/8560839/linker-error-when-using-an-extern-template


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

* [Bug c++/51629] Default Destructor and template extern Instantiation cause the Destructor to be missing
  2011-12-20  0:12 [Bug c++/51629] New: Default Destructor and template extern Instantiation cause the Destructor to be missing m_v_ at gmx dot net
  2011-12-20  0:13 ` [Bug c++/51629] " m_v_ at gmx dot net
@ 2011-12-20  6:28 ` paolo.carlini at oracle dot com
  2013-09-03 15:53 ` rob.desbois at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-12-20  6:28 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51629

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011-12-20
                 CC|m_v_ at gmx dot net         |jason at gcc dot gnu.org
     Ever Confirmed|0                           |1


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

* [Bug c++/51629] Default Destructor and template extern Instantiation cause the Destructor to be missing
  2011-12-20  0:12 [Bug c++/51629] New: Default Destructor and template extern Instantiation cause the Destructor to be missing m_v_ at gmx dot net
  2011-12-20  0:13 ` [Bug c++/51629] " m_v_ at gmx dot net
  2011-12-20  6:28 ` paolo.carlini at oracle dot com
@ 2013-09-03 15:53 ` rob.desbois at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: rob.desbois at gmail dot com @ 2013-09-03 15:53 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51629

rob.desbois at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rob.desbois at gmail dot com

--- Comment #2 from rob.desbois at gmail dot com ---
I believe I have incurred this same bug on gcc 4.7.2 with copy constructor, and
both move & copy assignment operators.
A workaround for my case is to have only the function declaration inline, and
to move the defaulted declaration out of line. Keeping everything else the same
- extern template declaration, explicit template instantiation, and file layout
- this yields the required results.


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

end of thread, other threads:[~2013-09-03 15:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-20  0:12 [Bug c++/51629] New: Default Destructor and template extern Instantiation cause the Destructor to be missing m_v_ at gmx dot net
2011-12-20  0:13 ` [Bug c++/51629] " m_v_ at gmx dot net
2011-12-20  6:28 ` paolo.carlini at oracle dot com
2013-09-03 15:53 ` rob.desbois at gmail dot com

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).