https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106633
Bug ID: 106633 Summary: Hidden visibility on forward declarations impacts visibility of default-visibility class methods Product: gcc Version: 12.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mh+gcc at glandium dot org Target Milestone: --- This was not happening before GCC 12. Reduced testcase from a Firefox build failure we got in Debian on armhf: ``` #pragma GCC visibility push(hidden) namespace std { class type_info; } #pragma GCC visibility pop #include <typeinfo> bool foo(std::type_info& a, std::type_info& b) { return a == b; } ``` Compile with `-O2 -D__GXX_TYPEINFO_EQUALITY_INLINE=0` (the define makes the problem appear on all platforms, rather than armhf only) What happens in this example is that the symbol reference to `std::type_info::operator==` ends up with hidden visibility, instead of default visibility. With GCC 11 and older versions, it would end up with default visibility. On godbolt: https://godbolt.org/z/hYKjWGaeq (Ironically(?), that forward declaration comes from ICU working around an old bug in libstdc++ headers)