[Mesa-dev] [Bug 107439] mesa defines likely/unlikely and these are C++20 keywords

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Wed Aug 1 22:10:26 UTC 2018


https://bugs.freedesktop.org/show_bug.cgi?id=107439

Casey Carter <Casey at Carter.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |Casey at Carter.net

--- Comment #2 from Casey Carter <Casey at Carter.net> ---
They're not technically keywords, they are "attribute-tokens". The problem is
that there is library wording in the Standard which forbids defining macros
with the same names as keywords, context-sensitive identifiers, and
attribute-tokens. C++17 [macro.names] para 2:

> A translation unit shall not #define or #undef names lexically identical to keywords, to the identifiers listed in Table 4, or to the attribute-tokens described in [dcl.attr].

When WG21 added "likely" and "unlikely" to [dcl.attr] in the C++20 working
draft, that made it implicitly forbidden to define them as macros. (Since The
change is a core language change the library groups never saw the proposal to
notice the problem.)

I've filed an issue with WG21 to change [macro.names]/2 to allow definitions of
"likely" and "unlikely" as function-like macros, which doesn't interfere with
use of the attributes [[likely]] and [[unlikely]] since there are no
parentheses to trigger expansion of a function-like macro. Assuming that the
rest of the Library Working Group agrees with me that we can't simply break
this much code for no good reason, you shouldn't need to change anything.

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are the QA Contact for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180801/65a1e8c4/attachment.html>


More information about the mesa-dev mailing list