Skip to content

Incorrect bool to integer cast #2804

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

Open
4 tasks done
annagrin opened this issue Apr 10, 2025 · 0 comments · May be fixed by #2805
Open
4 tasks done

Incorrect bool to integer cast #2804

annagrin opened this issue Apr 10, 2025 · 0 comments · May be fixed by #2805
Assignees

Comments

@annagrin
Copy link
Collaborator

Required prerequisites

  • Consult the security policy. If reporting a security vulnerability, do not report the bug using this form. Use the process described in the policy to report the issue.
  • Make sure you've read the documentation. Your issue may be addressed there.
  • Search the issue tracker to verify that this hasn't already been reported. +1 or comment there if it has.
  • If possible, make a PR with a failing test to give us a starting point to work on!

Describe the bug

(unsigned)(true) inside kernels is translated to a -1 constant instead of 1

Steps to reproduce the bug

struct testConstBool {
  auto operator()() __qpu__ {
    cudaq::qubit q;
    unsigned i = (unsigned)(true);
    if (i == 1) {
      x(q);
    }
  }
};

int main() {
  auto counts = cudaq::sample(testConstBool{});
  counts.dump();
}

Result:
{ 0: 1000 }

Expected behavior

{ 1: 1000 }

Is this a regression? If it is, put the last known working version (or commit) here.

Not a regression

Environment

  • CUDA-Q version:
  • Python version:
  • C++ compiler:
  • Operating system:

Suggestions

No response

@annagrin annagrin self-assigned this Apr 10, 2025
@annagrin annagrin linked a pull request Apr 10, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant