KhronosGroup / SYCL-Docs

SYCL Open Source Specification

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

steffenlarsen opened this issue · comments

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?

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.