Title
Removing placemarker tokens and retention of whitespace
Status
open
Section
15.6.4 [cpp.concat]
Submitter
Hubert Tong

Created on 2018-04-08.00:00:00 last changed 73 months ago

Messages

Date: 2022-02-18.07:47:23

It appears that the replacement of a function-like macro following further rescanning and replacement may begin or end with whitespace when the leftmost or rightmost tokens were placemarker tokens. GCC and MSVC preserve the whitespace in both the starting and ending positions. Clang and ICC preserve only the trailing whitespace. For example:

  #define F( X ) X##X/**/>
  #define G( X ) !/**/X##X
  #define F0( X ) F(X)
  #define G0( X ) G(X)
  #define STR2( X ) #X
  #define STR( X ) STR2(X)
  #define Q
  static_assert(STR(>F0(Q))[1] == '\u0020', STR(>F0(Q)));
    // ^ Works with GCC and MSVC; fails with Clang and ICC.
  static_assert(STR(G0(Q)=)[1] == '\u0020', STR(G0(Q)=));

This appears to be an issue in C as well; see ISO C 6.10.3.

See also issue 1625.

History
Date User Action Args
2018-04-08 00:00:00admincreate