-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Full name of submitter (unless configured in github; will be published with the issue): Hubert Tong
Reference (section label): [cpp.cond]
Link to reflector thread (if any): N/A
Issue description:
Consider https://godbolt.org/z/4d7bha7W4:
#define F(X) X
#if __has_include(F(<#.h>))
#endifhttps://wg21.link/cpp.cond#8 requires that the preprocessing tokens that appear in #if after "all macro replacements have occurred shall be in the lexical form of a token." https://wg21.link/cpp.cond#10 is clear that the macro replacements occur prior to evaluation (including evaluation of has-include-expressions, etc.). This means that the "token" requirement is enforced prior to the formation of header-names from header-name-tokens. Thus the above is ill-formed due to the # preprocessing token; however, that result seems unintended (and only EDG enforces it).
Paragraph 8 is generally redundant anyway: When the preprocessing tokens are converted into tokens in https://wg21.link/cpp.cond#11, https://wg21.link/lex.pptoken#2 applies.
Suggested resolution:
Strike [cpp.cond] paragraph 8:
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.