Bug 106633 - Hidden visibility on forward declarations impacts visibility of default-visibility class methods
Summary: Hidden visibility on forward declarations impacts visibility of default-visib...
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 12.1.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-08-15 23:44 UTC by Mike Hommey
Modified: 2022-08-16 01:05 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Hommey 2022-08-15 23:44:59 UTC
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)
Comment 1 Andrew Pinski 2022-08-15 23:50:31 UTC
I don't think this is a gcc bug but rather gcc 12 fixed a bug
Comment 2 Mike Hommey 2022-08-16 01:05:36 UTC
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...