https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86368

--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
It's quite unlikely (pun intended) that code randomly sprinkled with various
non-standard annotations (attributes, pragmas, or otherwise) will eventually
have the same effect across all implementations once they recognize it.  With
the attribute spec as loose as it is, implementations haven't even converged on
the same effect for the standard attributes, so there is little chance that
they will for those that aren't specified.

I think the expected progression of new attributes is from vendor namespaces to
the standard global namespace and so, as Jonathan suggests, not warning by
default for unknown attributes in other vendor's namespaces (e.g.,
[[foo:unlikely]] might be reasonable.  Warning for unknown attributes in the
global namespace (i.e., [[unlikely]]) or in our own (i.e., [[gnu::unlikely]])
is the right choice.

As an aside, while the C++ standard doesn't allow C++ programs to define macros
with the same names as those of standard attributes, nothing prevents a
non-standard attributes from being #defined as macros (and since C doesn't
support attributes of any kind yet, nothing prevents library headers written in
C from #defining even C++ standard attributes as macros).  This makes relying
on non-standard attributes in library headers problematic in either language
(and points to a design flaw in the attribute design).

Reply via email to