public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/39159]  New: unhelpful attribute warning on matching declaration after definition
@ 2009-02-11 23:50 sebor at roguewave dot com
  2009-02-12 17:02 ` [Bug c++/39159] " sebor at roguewave dot com
  0 siblings, 1 reply; 2+ messages in thread
From: sebor at roguewave dot com @ 2009-02-11 23:50 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/39159] unhelpful attribute warning on matching declaration after definition
  2009-02-11 23:50 [Bug c++/39159] New: unhelpful attribute warning on matching declaration after definition sebor at roguewave dot com
@ 2009-02-12 17:02 ` sebor at roguewave dot com
  0 siblings, 0 replies; 2+ messages in thread
From: sebor at roguewave dot com @ 2009-02-12 17:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from sebor at roguewave dot com  2009-02-12 17:02 -------
In addition, as the test case below shows, the warning is issued inconsistently
between classes and functions, suggesting that the instance of the warning on
the class declaration on line 2 might be a bug rather than a feature:

$ cat -n t.C && g++ -dumpversion && g++ -c t.C
     1  struct __attribute__ ((visibility ("default"))) A { };
     2  struct __attribute__ ((visibility ("default"))) A;
     3
     4  void __attribute__ ((visibility ("default"))) foo () { }
     5  void __attribute__ ((visibility ("default"))) foo ();
4.3.1
t.C:2: warning: type attributes ignored after type is already defined


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39159


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-02-12 17:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-11 23:50 [Bug c++/39159] New: unhelpful attribute warning on matching declaration after definition sebor at roguewave dot com
2009-02-12 17:02 ` [Bug c++/39159] " sebor at roguewave dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).