Title
Allowing #undef likely
Status
open
Section
15.7.1 [cpp.replace.general]
Submitter
Jakub Jelinek

Created on 2025-07-31.00:00:00 last changed 1 month ago

Messages

Date: 2025-07-31.00:00:00

(From submission #734.)

P2843 moved a prohibition to #define keywords to the core language; it is now appearing in 15.7.1 [cpp.replace.general] paragraph 9:

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 9.13 [dcl.attr], except that the names likely and unlikely may be defined as function-like macros.

This allows

  #define likely(x) x
  #define unlikely(a, b) a + b

but prohibits

  #undef likely
  #undef unlikely

even though guidelines for good macro hygiene suggest to #undef a macro past its region of use.

Possible resolution:

Change in 15.7.1 [cpp.replace.general] paragraph 9 as follows:

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 9.13 [dcl.attr], except that the names likely and unlikely may be defined as function-like macros and may be undefined.
History
Date User Action Args
2025-07-31 00:00:00admincreate