fix undefined behaviors (#2130)

* fix undefined behaviours

* Run clang format 15 instead of 18

* OpenMP for statement must have signed integral type

---------

Co-authored-by: Jun Doi <doichan@jp.ibm.com>
This commit is contained in:
Saman 2024-07-09 00:25:27 -07:00 committed by GitHub
parent 322e786b90
commit e56cbbbd97
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 5 additions and 5 deletions

View File

@ -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 {

View File

@ -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()));

View File

@ -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()));

View File

@ -259,7 +259,7 @@ protected:
// 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;

View File

@ -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()));