Summary: | mesa defines likely/unlikely and these are C++20 keywords | ||
---|---|---|---|
Product: | Mesa | Reporter: | Bruce Dawson <brucedawson> |
Component: | Mesa core | Assignee: | mesa-dev |
Status: | RESOLVED MOVED | QA Contact: | mesa-dev |
Severity: | normal | ||
Priority: | medium | CC: | Casey |
Version: | git | ||
Hardware: | Other | ||
OS: | All | ||
Whiteboard: | |||
i915 platform: | i915 features: |
Description
Bruce Dawson
2018-07-31 23:47:36 UTC
Are these really reserved keywords? I thought the attribute namespace was different from the keyword namespace. These are not listed as keywords, even for C++20: https://en.cppreference.com/w/cpp/keyword You should be able to define variables called "likely", for example. https://wandbox.org/permlink/hFczuKlzyOjFjvkA Using the [[likely]] syntax while having likely() defined as a macro might be a problem though, but that is a separate issue. 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.
-- GitLab Migration Automatic Message -- This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/mesa/mesa/issues/1029. |
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.