KhronosGroup / SYCL-Docs

SYCL Open Source Specification
Other
116 stars 68 forks source link

Should creating a 0-dimensional accessor with an empty buffer be legal? #435

Open steffenlarsen opened 1 year ago

steffenlarsen commented 1 year ago

The SYCL 2020 specification doesn't currently disallow creating a 0-dimensional accessor from an empty buffer, similar to how accessors with other dimensionalities. However, since access to a 0-dimensional accessor isn't through subscript but rather through implicit conversion to a reference to the first element in the associated memory, having an empty 0-dimensional accessor may come as a surprise to the user and invalid accesses may be hard to locate.

Are there good use-cases for empty 0-dimensional accessors? If not, should the constructor throw is one is created?

keryell commented 1 year ago

This sounds legal to me. Of course you should not use the implicit conversion operator, in the same way you can not access element [0] for an empty 1-D buffer for example.