KhronosGroup / KhronosGroup/OpenCL-Docs

Reserved ^^ operator parsing ambiguity

Open
#1,264 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
420
Forks
131
Avg merge
5d 13h
Merged PRs (30d)
11

Description

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?

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the OpenCL C example in the linked Compiler Explorer and compare the reserved `^^` token with the blocks syntax. Read the issue’s references to OpenCL 3.0 and the WG21 reflection proposal, then determine whether the reservation should change. Done means the specification’s treatment of `^^` clearly resolves the immediately called block case.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
compilers, documentation
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.