LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 12255 - with -fvisibility-inlines-hidden needed copy not emitted for virtual inline function
Summary: with -fvisibility-inlines-hidden needed copy not emitted for virtual inline f...
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: -New Bugs (show other bugs)
Version: trunk
Hardware: PC Linux
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on: 11250
Blocks:
  Show dependency tree
 
Reported: 2012-03-12 13:32 PDT by Luboš Luňák
Modified: 2013-02-07 11:12 PST (History)
5 users (show)

See Also:
Fixed By Commit(s):


Attachments
testcase (518 bytes, application/x-shellscript)
2012-03-12 13:32 PDT, Luboš Luňák
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Luboš Luňák 2012-03-12 13:32:31 PDT
Created attachment 8196 [details]
testcase

+++ This bug was initially created as a clone of Bug #11250 +++

This bug is based on bug #11250, which manually marked a base class template as hidden, resulting in an undefined reference when clang expected to find the instance of the template in another .so . This bug is the same, except that it uses the -fvisibility-inlines-hidden option.

In the original testcase, one could argue that the problem is in the source
files and not in clang. In lib2.cc, clang is apparently smart enough to see
that it is not necessary to instantiate S1< int >, because it will be done in
the same place where S2::~S2() is implemented (since S2's vtable is keyed to
it, as the first virtual method in S2, and S2's vtable will require vtable of
S1< int >, which will also instantiate S1< int >::f()). Therefore it could be
argued that it is a developer error to mark S1 as non-exported (especially
since it's done so only in lib1.cc and not in lib2.cc ).

However, this new testcase compiles and links fine as it is, as long as
-fvisibility-inlines-hidden is not used, otherwise the same problem occurs. Now
again lib1.so contains a non-exported instance of S1< int >::f(), because of
the switch.

Presumably when compiling with -fvisibility-inlines-hidden clang should create
a non-exported instance of S1< int >::f() even in lib2.so , otherwise
-fvisibility-inlines-hidden is broken or next to useless.
Comment 1 Luboš Luňák 2013-02-07 11:12:29 PST
This has apparently gotten fixed somewhen on the way to 3.2.