Skip to content

Commit

Permalink
fix undefined behaviors (#2130)
Browse files Browse the repository at this point in the history
* fix undefined behaviours

* Run clang format 15 instead of 18

* OpenMP for statement must have signed integral type

---------

Co-authored-by: Jun Doi <[email protected]>
  • Loading branch information
enum-class and doichanj authored Jul 9, 2024
1 parent 322e786 commit e56cbbb
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/framework/operations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1775,7 +1775,7 @@ Op input_to_op_bfunc(const inputdata_t &input) {
auto it = comp_table.find(relation);
if (it == comp_table.end()) {
std::stringstream msg;
msg << "Invalid bfunc relation string :\"" << it->first << "\"."
msg << "Invalid bfunc relation string :\"" << relation << "\"."
<< std::endl;
throw std::invalid_argument(msg.str());
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/simulators/density_matrix/densitymatrix_executor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,7 @@ Executor<densmat_t>::sample_measure(const reg_t &qubits, uint_t shots,
#endif

// Convert to SampleVector format
int_t npar = Base::parallel_state_update_;
uint_t npar = Base::parallel_state_update_;
if (npar > local_samples.size())
npar = local_samples.size();
std::vector<SampleVector> all_samples(shots, SampleVector(qubits.size()));
Expand Down
2 changes: 1 addition & 1 deletion src/simulators/density_matrix/densitymatrix_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ std::vector<SampleVector> State<densmat_t>::sample_measure(const reg_t &qubits,
allbit_samples = BaseState::qreg_.sample_measure(rnds);

// Convert to bit format
int_t npar = BaseState::threads_;
uint_t npar = BaseState::threads_;
if (npar > shots)
npar = shots;
std::vector<SampleVector> all_samples(shots, SampleVector(qubits.size()));
Expand Down
2 changes: 1 addition & 1 deletion src/simulators/state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ class Base {

// Maximum threads which may be used by the backend for OpenMP multithreading
// Default value is single-threaded unless overridden
int threads_ = 1;
uint_t threads_ = 1;

// Set a global phase exp(1j * theta) for the state
bool has_global_phase_ = false;
Expand Down
2 changes: 1 addition & 1 deletion src/simulators/statevector/statevector_executor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,7 @@ Executor<state_t>::sample_measure(const reg_t &qubits, uint_t shots,
#endif

// Convert to SampleVector format
int_t npar = Base::parallel_state_update_;
uint_t npar = Base::parallel_state_update_;
if (npar > local_samples.size())
npar = local_samples.size();
std::vector<SampleVector> all_samples(shots, SampleVector(qubits.size()));
Expand Down

0 comments on commit e56cbbb

Please sign in to comment.