User account creation filtered due to spam.

Bug 53182 - GNU C: attributes without underscores should be discouraged / no longer be documented e.g. as examples
Summary: GNU C: attributes without underscores should be discouraged / no longer be do...
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: unknown
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
Keywords: documentation
Depends on:
Reported: 2012-05-02 01:39 UTC by Vincent Lefèvre
Modified: 2012-05-02 13:27 UTC (History)
1 user (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed: 2012-05-02 00:00:00


Note You need to log in before you can comment on or make changes to this bug.
Description Vincent Lefèvre 2012-05-02 01:39:44 UTC
Attributes without underscores can conflict with the ISO C standard. For instance, if the C11 <stdnoreturn.h> header is included, this breaks GCC's

  __attribute__ ((noreturn))

(such problems may occur in particular if different libraries, with different expectations, are used). To avoid such a clash, only the __noreturn__ version should be used. Other attributes without __ may also lead to conflicts with a future C standard. You can see

and the corresponding discussion, from which I've reported this bug.

I suggest the following changes:

* Fix the GCC manual: the versions without __ should be discouraged (explain why) and the examples should always use the __ version, e.g. change

          void fatal () __attribute__ ((noreturn));


          void fatal () __attribute__ ((__noreturn__));

* Possibly issue a warning if an attribute without __ is used.
Comment 1 Richard Biener 2012-05-02 11:54:02 UTC
Comment 2 Eric Blake 2012-05-02 13:27:28 UTC
It would also help to add an attribute named __attribute__((_Noreturn)) (and therefore also adding __attribute__((___Noreturn__)), of course), for this particular instance of <stdnoreturn.h> vs. existing code.