AaronBallman wrote:

> TMK, the wording says that the third number in the diagnostic message from 
> the `static_assert` below should be less than the second because replacement 
> of `__VA_OPT__` with its expanded replacement occurs before the other 
> instance of `__COUNTER__` in the replacement list is encountered during 
> rescanning and further replacement.
> 
> Clang generates `"0 2 3 1"`. The `2` and `3` is transposed compared to 
> expectations.
> 
> ```c
> #define STR0(X)  #X
> #define STR(X) STR0(X)
> #define F(X, Y, ...) STR(Y __COUNTER__ __VA_OPT__(__COUNTER__) X)
> static_assert(0, F(__COUNTER__, __COUNTER__, hi));
> ```
> 
> https://godbolt.org/z/aYGEq94va

Clang and GCC get the same behavior, EDG has `1 2 3 0`, and MSVC comes up with 
`1 2 __VA_OPT__(3) 0` so there's implementation divergence; changing the 
behavior to deviate from GCC seems like something we may want to consider 
outside of the scope of this particular PR. How about I add test coverage for 
this with a FIXME comment and mark our support as partial? Then I can file an 
issue to track the behavior and we can get around to fixing that when we do.

https://github.com/llvm/llvm-project/pull/162662
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to