Title
Definitions of "likely" and "unlikely" are likely to cause problems
Status
c++20
Section
[macro.names]
Submitter
Casey Carter

Created on 2018-08-01.00:00:00 last changed 45 months ago

Messages

Date: 2018-11-12.04:39:29

Proposed resolution:

This wording is relative to N4762.

  1. Change [macro.names] as indicated:

    [Drafting Note: If both this proposed resolution and the proposed resolution of LWG 3132 are accepted, the text inserted by LWG 3132 should precede the text added here.]

    -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], except that the names likely and unlikely may be defined as function-like macros ([cpp.replace]).

Date: 2018-11-12.04:39:29

[ 2018-11, Adopted in San Diego ]

Date: 2018-08-20.00:00:00

[ 2018-08-20 Status to Tentatively Ready after five positive votes on the reflector. ]

Date: 2018-08-01.00:00:00

[macro.names]/2 forbids a translation unit to define names "lexically identical to […] the attribute-tokens described in [dcl.attr]." We recently added the attribute-tokens likely and unlikely ([dcl.attr.likelihood]). These names are in extremely wide use as function-like macros in the open source community, forbidding users to define them breaks large amounts of code. (Reportedly Chromium contains 19 definitions each of "likely" and "unlikely" as function-like macros.)

Indeed, this issue came up during EWG discussion of P0479R1 "Attributes for Likely and Unlikely Statements" in Kona, and EWG decided to keep the names "likely" and "unlikely" for the attribute tokens since the usage wouldn't conflict with defining them as function-like macros. [macro.names]/2 should not break large amounts of existing code that doesn't actually conflict with the use of the [[likely]] and [[unlikely]] attributes.

History
Date User Action Args
2021-02-25 10:48:01adminsetstatus: wp -> c++20
2018-11-12 04:39:29adminsetmessages: + msg10205
2018-11-12 04:39:29adminsetstatus: voting -> wp
2018-10-08 05:13:59adminsetstatus: ready -> voting
2018-08-20 12:41:52adminsetmessages: + msg10077
2018-08-20 12:41:52adminsetstatus: new -> ready
2018-08-04 14:48:57adminsetmessages: + msg10053
2018-08-01 00:00:00admincreate