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

2024-04-18


2522. Removing placemarker tokens and retention of whitespace

Section: 15.6.4  [cpp.concat]     Status: open     Submitter: Hubert Tong     Date: 2018-04-08     Liaison: WG14

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.