https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93922
Bug ID: 93922
Summary: Fails to emit inline class template destructor
instantiation, but which is called
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: sbergman at redhat dot com
Target Milestone: ---
I came across this when building LibreOffice and its bundled Skia with recent
GCC 10 trunk and it failed to link due to two undefined references. I hope the
below is a faithfully stripped-down reproducer for the error I encountered:
> $ cat test.cc
> template<typename T> struct sk_sp {
> template<typename U> sk_sp(sk_sp<U> const &);
> ~sk_sp() {}
> };
> struct SkPicture {};
> struct Wrapped: SkPicture {
> Wrapped(SkPicture const &);
> };
> struct S {
> sk_sp<SkPicture const> x;
> Wrapped y;
> };
> sk_sp<SkPicture> ref(SkPicture *);
> void f(SkPicture * x, SkPicture const & y) {
> new S(ref(x), y);
> }
> $ g++ -std=c++2a -S test.cc -o - | grep _ZN5sk_spIK9SkPictureED1Ev
> call _ZN5sk_spIK9SkPictureED1Ev
shows that sk_sp<SkPicture const>::~sk_sp() (i.e., _ZN5sk_spIK9SkPictureED1Ev)
is called (from f) but not emitted.