-fvisibility-inlines-hidden not effective for templated functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Greetings.


I observe that templated inline functions are unaffected by
-fvisibility-inlines-hidden (`nm -D` still lists symbols like "0123 W
_ZNK3bar8fortytwoIiEEKiT_"), and this seems even expected to some
degree, quoting gcc.1:

	Explicitly instantiated inline methods are unaffected by this
	option as their linkage might otherwise cross a shared
	library boundary.

However, if I am not mistaken, the following snippet relies on
implicit instantiation. Am I observing a gcc bug here?

(Also, the manpage paragraph, if unrolled, would read "if inline
methods were affected by -fvi.., then their linkage would cross a
boundary". But since they would be hidden, how could they cross a
boundary?)


struct __attribute__((visibility("default"))) bar {
        constexpr inline const int fortyone(void) { return 41; }
        template<typename T> constexpr inline const int
        fortytwo(T x) const { return 42; }
};
void f(void) {
        bar b;
        b.fortyone();
        b.fortytwo(0);
}

Using built-in specs.
COLLECT_GCC=g++-6
COLLECT_LTO_WRAPPER=/usr/lib64/gcc/x86_64-suse-linux/6/lto-wrapper
Target: x86_64-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64 --enable-languages=c,c++,objc,fortran,obj-c++,java,ada,go --enable-offload-targets=hsa --enable-checking=release --with-gxx-include-dir=/usr/include/c++/6 --enable-ssp --disable-libssp --disable-libvtv --disable-libcc1 --disable-plugin --with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux' --disable-libgcj --with-slibdir=/lib64 --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch --with-default-libstdcxx-abi=gcc4-compatible --enable-version-specific-runtime-libs --enable-linker-build-id --enable-linux-futex --enable-gnu-indirect-function --program-suffix=-6 --without-system-libunwind --enable-multilib --with-arch-32=x86-64 --with-tune=generic --build=x86_64-suse-linux --host=x86_64-suse-linux
Thread model: posix
gcc version 6.2.1 20161103 [gcc-6-branch revision 241818] (SUSE Linux) 



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux