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)
I don't think this is a gcc bug but rather gcc 12 fixed a bug
Started with https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=a53781c8fd258608780821168a7f5faf7be63690;hp=ba9b07d0259b38a9eccd4eb0df327d3aaabad3c6 ... which points to the fact that this is now consistent with the behavior of forward declarations of any other class...