gcc 4.3 issues a warning for the declaration of struct A below despite the attribute on the declaration being consistent with that on the definition and thus benign. While the warning is valuable in cases where the attributes between the declaration and the definition do not match, it is not useful in benign cases such as the one below. In these cases the warning makes applying the attribute difficult in existing C++ libraries that rely heavily but not completely on forward declarations and that also already make use of the Visual C++ __declspec(dllexport) feature or the Sun C++ __global or __protected specifiers, neither of which warns about such benign cases.
$ cat t.C && g++ -c t.C struct __attribute__ ((visibility ("default"))) A { }; struct __attribute__ ((visibility ("default"))) A; t.C:2: warning: type attributes ignored after type is already defined -- Summary: unhelpful attribute warning on matching declaration after definition Product: gcc Version: 4.3.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: sebor at roguewave dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39159