https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119696
Bug ID: 119696
Summary: Visibility warning when using a
pointer-to-member-function to a hidden member method
as a template argument
Product: gcc
Version: 14.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: cfsteefel at arista dot com
Target Milestone: ---
There seems to be a new warning in gcc14 when a pointer-to-member-function is
used as a template argument, if that member-function has hidden visibility.
See the following code and error message:
class FooSpan {
int s_;
public:
int s() const noexcept __attribute__(( visibility("hidden"))){ return s_; }
};
template< auto _f = nullptr >
class Funktor {
public:
static constexpr auto f = _f;
};
class Funky : public Funktor< &FooSpan::s > {
using Funktor::f;
};
class Funkier {
Funktor< &FooSpan::s > f;
};
When compiled with only "g++", error:
<source>:15:7: warning: 'Funky' declared with greater visibility than its base
'Funktor<&FooSpan::s>' [-Wattributes]
15 | class Funky : public Funktor< &FooSpan::s > {
| ^~~~~
<source>:19:7: warning: 'Funkier' declared with greater visibility than the
type of its field 'Funkier::f' [-Wattributes]
19 | class Funkier {
| ^~~~~~~
This was tested on godbolt.org with gcc14.1, as well as gcc-toolset-14 from
Alma9 linux.
The warning does not appear to exist in earlier gcc versions.
This is also reproducible if "-fvisibility-inlines-hidden" is used, even if the
member method has no visibility modifier specified.
This is a behavioral change, leading to code that formerly compiled with
-Werror no longer compiling.