OpenCL-Docs icon indicating copy to clipboard operation
OpenCL-Docs copied to clipboard

Reserved ^^ operator parsing ambiguity

Open AaronBallman opened this issue 1 year ago • 0 comments

OpenCL 3.0 (and earlier) reserves the ^^ token. However, OpenCL also works with (and encourages use of) the blocks extension, which uses ^ as part of its block expression syntax. This leads to an ambiguity with an immediately called block, as in:

unsigned x=0;
unsigned y=x^^{return 0;}();

This should result in y holding the value zero (0^0) through an immediately invoked block call as the right-hand side of the xor operator. However, it causes errors instead because of this reserved token: https://godbolt.org/z/navf7jTv1

Immediately called blocks (and lambdas) are not uncommon, so perhaps this is a reason to no longer reserve ^^ as a token. Another thing to consider is that WG21 is considering using ^^ as a token for reflection: https://isocpp.org/files/papers/P3381R0.html

Perhaps this token should no longer be reserved in OpenCL?

AaronBallman avatar Sep 16 '24 11:09 AaronBallman