https://gcc.gnu.org/bugzilla/show_bug.cgi?id=20345
Vadim Zeitlin <vz-gcc at zeitlins dot org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |vz-gcc at zeitlins dot org --- Comment #3 from Vadim Zeitlin <vz-gcc at zeitlins dot org> --- Surprisingly, after all these years I've realized just now that this bug has never been actually fixed. The patch that was applied fixes the warnings in the following code: struct __attribute__((visibility("default"))) S; struct __attribute__((visibility("default"))) S { }; but it did nothing for this case: struct __attribute__((visibility("default"))) S { }; struct __attribute__((visibility("default"))) S; All versions of g++ I have (4.[6789] and 5.2) still give a warning in this case, e.g. with 5.2.1 and the code above in the file visibility.cpp: % g++ -Wall -fvisibility=hidden -c visibility.cpp visibility.cpp:2:47: warning: type attributes ignored after type is already defined [-Wattributes] struct __attribute__((visibility("default"))) S; ^ And, of course, while nobody is going to write code like above manually intentionally, it's pretty common to encounter it in more complicated cases when various headers forward declare various classes and can be included in more or less any order. So in practice using visibility attributes in forward declarations still remains impossible (without getting flooded with warnings, that is), although it would be very nice for projects adding visibility support (yes, in 2015, better late than never...) to the existing code which happily compiles without any warnings using MSVC. IMO gcc should verify that the class is either not fully declared with a different visibility instead of just checking that it's not fully declared at all.