sg22-c-cpp-standard-compatibility / sg-compatibility

A joint Study Group between the C (WG14) and C++ (WG21) Committees to ensure the longterm synchronization and cooperation of the C and C++ programming languages where any mutual interests lie.
1 stars 0 forks source link

CWG #2522: Removing placemarker tokens and retention of whitespace #27

Open NinaRanns opened 10 months ago

NinaRanns commented 10 months ago

Notify WG14 of the following WG21 CWG issue which is also present in C standard.

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

CWG Issue