Title
Token convertibility requirement in #if
Status
tentatively ready
Section
15.2 [cpp.cond]
Submitter
Hubert Tong

Created on 2025-11-18.00:00:00 last changed 7 days ago

Messages

Date: 2025-12-05.21:43:30

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]).
Date: 2025-11-18.00:00:00

(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.

History
Date User Action Args
2025-12-05 21:43:30adminsetstatus: open -> tentatively ready
2025-11-18 21:59:36adminsetmessages: + msg8394
2025-11-18 00:00:00admincreate