[Bug c++/47877] -fvisibility-inlines-hidden does not hide member template functions
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47877 Jason Merrill changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED Target Milestone|--- |10.0 --- Comment #7 from Jason Merrill --- Fixed for GCC 10.
[Bug c++/47877] -fvisibility-inlines-hidden does not hide member template functions
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47877 --- Comment #6 from Jason Merrill --- Author: jason Date: Tue Jan 7 15:05:25 2020 New Revision: 279960 URL: https://gcc.gnu.org/viewcvs?rev=279960=gcc=rev Log: PR c++/47877 - -fvisibility-inlines-hidden and member templates. DECL_VISIBILITY_SPECIFIED is also true if an enclosing scope has explicit visibility, and we don't want that to override -fvisibility-inlines-hidden. So check for the attribute specifically on the function, like we already do for template argument visibility restriction. * decl2.c (determine_visibility): -fvisibility-inlines-hidden beats explicit class visibility for a template. Added: trunk/gcc/testsuite/g++.dg/ext/visibility/fvisibility-inlines-hidden-5.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/decl2.c trunk/gcc/tree.h
[Bug c++/47877] -fvisibility-inlines-hidden does not hide member template functions
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47877 Jason Merrill changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |jason at gcc dot gnu.org
[Bug c++/47877] -fvisibility-inlines-hidden does not hide member template functions
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47877 Alexander Monakov changed: What|Removed |Added CC||amonakov at gcc dot gnu.org --- Comment #5 from Alexander Monakov --- In PR 92855 we have a similar situation where an inline template function inherits visibility from the enclosing namespace, while a non-template function becomes hidden as requested by -fvisibility-inlines-hidden: namespace N __attribute__((visibility("default"))) { inline void foo() {}; template inline void bar() {}; } int main() { N::foo(); N::bar(); }
[Bug c++/47877] -fvisibility-inlines-hidden does not hide member template functions
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47877 Alexander Monakov changed: What|Removed |Added CC||thiago at kde dot org --- Comment #4 from Alexander Monakov --- *** Bug 92855 has been marked as a duplicate of this bug. ***
[Bug c++/47877] -fvisibility-inlines-hidden does not hide member template functions
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47877 --- Comment #3 from Jan Engelhardt --- Hm yes, I begin to see why this was done. Template instantiations show up as W-type symbols in `nm`, and template specializations are 'T'-type, and both need to be visible so that the override works. But only on -O0. When compiling with -O2, the template instantiations gets inlined and the symbol (_ZN3Foo3barIS_EEvv in this example) disappears because of -fvisibility-inlines-hidden and could not possibly be overridden. So template specializations from elsewhere will have no effect. ... So IMO we can probably just drop the "!processing_template_decl" part.
[Bug c++/47877] -fvisibility-inlines-hidden does not hide member template functions
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47877 Richard Biener changed: What|Removed |Added Keywords||documentation Status|UNCONFIRMED |NEW Last reconfirmed||2016-11-21 CC|rguenther at suse dot de |jason at gcc dot gnu.org, ||rguenth at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #2 from Richard Biener --- Confirmed. It looks like template instantiation somehow ends up using the explicitely specified visibility from the class. When determine_visibility_from_class is called for the template determine_hidden_inline () is false because of the processing_template_decl check. So the behavior is clearly on purpose and thus a documentation issue(?): /* Returns true iff DECL is an inline that should get hidden visibility because of -fvisibility-inlines-hidden. */ static bool determine_hidden_inline (tree decl) { return (visibility_options.inlines_hidden /* Don't do this for inline templates; specializations might not be inline, and we don't want them to inherit the hidden visibility. We'll set it here for all inline instantiations. */ && !processing_template_decl && TREE_CODE (decl) == FUNCTION_DECL && DECL_DECLARED_INLINE_P (decl) && (! DECL_LANG_SPECIFIC (decl) || ! DECL_EXPLICIT_INSTANTIATION (decl))); } so the reason is along non-inline specializations (not sure why we'd want to avoid mixed visibility here).
[Bug c++/47877] -fvisibility-inlines-hidden does not hide member template functions
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47877 Jan Engelhardt changed: What|Removed |Added CC||jengelh at inai dot de, ||rguenther at suse dot de --- Comment #1 from Jan Engelhardt --- The issue persists with gcc 6.2.1 and was also posted at https://www.spinics.net/lists/gcchelp/msg46007.html with more detail.