Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify whether arrays and bit registers of size 0 are allowed #532

Open
garrison opened this issue Apr 24, 2024 · 1 comment
Open

Clarify whether arrays and bit registers of size 0 are allowed #532

garrison opened this issue Apr 24, 2024 · 1 comment
Labels
enhancement default GH label

Comments

@garrison
Copy link
Contributor

garrison commented Apr 24, 2024

What is the expected enhancement?

I suggest that it should be stated explicitly whether bit registers or statically-sized arrays of size 0 are allowed by the spec.

Since it is not currently mentioned, I believe that registers with zero bits should be supported, but qe-qasm does not currently support them: openqasm/qe-qasm#37.

For what it's worth, a zero-sized array on the stack is disallowed in C by the standard. However, I think there is a stronger case for allowing them in OpenQASM, for two reasons:

  1. An unused empty array in a C can be eliminated from the code and replaced with NULL without the semantics of that code changing, AFAICT. By contrast, removing an output array register of zero bits from an OpenQASM program would change the result; the register would no longer be included in the output.
  2. OpenQASM code is often generated by a computer program, and the output is typically consumed by a computer program. Running a program, with certain inputs, might sometimes result in a classical register of zero size, and it would be nice not to have to special case this both when the OpenQASM is generated and when the output is consumed.

If it is decided instead that arrays of size 0 should not be allowed, then I suggest that it be clarified that every dimension of the array must be at least 1 (e.g., array[float[32], 3, 0, 2] would contain zero elements and therefore also be disallowed).

@garrison garrison added the enhancement default GH label label Apr 24, 2024
@levbishop
Copy link
Contributor

levbishop commented May 15, 2024

From my opinion a zero-size register feels fine for the 2 reasons given. If you u are able to PR to implement the spec change, it will be easier to validate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement default GH label
Projects
None yet
Development

No branches or pull requests

2 participants