Bug 25592 - template struct with visibility set to default and -fvisibility=hidden
Summary: template struct with visibility set to default and -fvisibility=hidden
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.0
: P3 normal
Target Milestone: 4.1.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-28 19:55 UTC by Aristid Breitkreuz
Modified: 2005-12-28 20:19 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Aristid Breitkreuz 2005-12-28 19:55:23 UTC
The following code compiled with -fvisibility=hidden produces only typeinfo symbols with hidden visibility:

#define GOTT_EXPORT __attribute__ ((visibility("default")))

template<class T> struct GOTT_EXPORT spelled_t {};

template<class T>
inline std::type_info const &spell() {
  return typeid(spelled_t<T>);
}

... spell<long>()

readelf -sW says:

  1441: 0000000000180800    16 OBJECT  LOCAL  HIDDEN   22 _ZTIN4gott4xany9spelled_tIlEE
  2536: 0000000000058cb0    26 OBJECT  LOCAL  HIDDEN   12 _ZTSN4gott4xany9spelled_tIlEE

gcc -v says:

Reading specs from /usr/lib/gcc/x86_64-pc-linux-gnu/3.4.4/specs
Configured with: /var/tmp/portage/gcc-3.4.4-r1/work/gcc-3.4.4/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/3.4.4 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/3.4.4/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/3.4.4 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/3.4.4/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/3.4.4/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/3.4.4/include/g++-v3 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --disable-libunwind-exceptions --enable-multilib --disable-libmudflap --disable-libgcj --enable-languages=c,c++ --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
Thread model: posix
gcc version 3.4.4 (Gentoo 3.4.4-r1, ssp-3.4.4-1.0, pie-8.7.8)
Comment 1 Andrew Pinski 2005-12-28 20:05:40 UTC
Simplified testcase:
#include <typeinfo>
template<typename T> struct __attribute__ ((visibility("default"))) Abc{
~Abc(){}
Abc(){}
};

const std::type_info *f(void)
{
  return &typeid(Abc<int>);

}
Comment 2 Andrew Pinski 2005-12-28 20:19:57 UTC
Fixed in 4.1.0.