This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 119a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2025-12-20


3125. Token convertibility requirement in #if

Section: 15.2  [cpp.cond]     Status: tentatively ready     Submitter: Hubert Tong     Date: 2025-11-18

(From submission #813.)

Consider:

  #define F(X) X
  #if __has_include(F(<#.h>))
  #endif

This is ill-formed per 15.2 [cpp.cond] paragraph 8, even though the # preprocessing token will eventually be used to form a header-name and thus will not be converted into a token per 15.2 [cpp.cond] paragraph 11. The latter is governed by 5.5 [lex.pptoken] paragraph 2.

Proposed resolution (approved by CWG 2025-12-05):

Change in 15.2 [cpp.cond] paragraph 8 as follows:

Each preprocessing token that remains (in the list of preprocessing tokens that will become the controlling expression) after all macro replacements have occurred shall be in the lexical form of a token (5.10 [lex.token]).