Skip to content

Commit

Permalink
Fixes a bug with C++ argument handling in the front end. (#2459)
Browse files Browse the repository at this point in the history
This one particular path was not making sure the arguments were relaxed
when they needed to be resulting in a type error.

As a bonus, corrects the bernstein_vazirani example.

Signed-off-by: Eric Schweitz <[email protected]>
  • Loading branch information
schweitzpgi authored Dec 10, 2024
1 parent 95a4da7 commit 917146d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/sphinx/applications/cpp/bernstein_vazirani.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ std::vector<bool> random_bits(int seed) {

template <int nrOfBits>
struct oracle {
auto operator()(std::vector<bool> bitvector, cudaq::qview<> qs,
auto operator()(std::vector<bool> &bitvector, cudaq::qview<> qs,
cudaq::qubit &aux) __qpu__ {

for (size_t i = 0; i < nrOfBits; i++) {
Expand Down
4 changes: 3 additions & 1 deletion lib/Frontend/nvqpp/ConvertExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2310,8 +2310,10 @@ bool QuakeBridgeVisitor::VisitCXXOperatorCallExpr(
// replace it with an indirect call to the func::ConstantOp.
auto indirect = popValue();
auto funcTy = cast<FunctionType>(indirect.getType());
auto convertedArgs =
convertKernelArgs(builder, loc, 0, args, funcTy.getInputs());
auto call = builder.create<func::CallIndirectOp>(
loc, funcTy.getResults(), indirect, args);
loc, funcTy.getResults(), indirect, convertedArgs);
if (call.getResults().empty())
return true;
return pushValue(call.getResult(0));
Expand Down

0 comments on commit 917146d

Please sign in to comment.