Bug 53182 - GNU C: attributes without underscores should be discouraged / no longer be documented e.g. as examples
GNU C: attributes without underscores should be discouraged / no longer be do...
Status: NEW
Product: gcc
Classification: Unclassified
Component: c
unknown
: P3 enhancement
: ---
Assigned To: Not yet assigned to anyone
: documentation
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-05-02 01:39 UTC by Vincent Lefèvre
Modified: 2012-05-02 13:27 UTC (History)
1 user (show)

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


Attachments

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

  http://lists.gnu.org/archive/html/bug-gnulib/2012-05/msg00024.html

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));

to

          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
Confirmed.
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.