diff --git a/src/simulators/circuit_executor.hpp b/src/simulators/circuit_executor.hpp index eb0ae1886f..d3a9277a6a 100644 --- a/src/simulators/circuit_executor.hpp +++ b/src/simulators/circuit_executor.hpp @@ -871,9 +871,8 @@ void Executor::run_circuit_shots( // run each shot auto run_circuit_lambda = [this, &par_results, circ, noise, config, par_shots, - sample_noise, num_shots, shot_begin, &cregs, - init_rng, max_matrix_qubits, - num_local_shots](int_t i) { + sample_noise, shot_begin, &cregs, init_rng, + max_matrix_qubits, num_local_shots](int_t i) { state_t state; uint_t i_shot, e_shot; i_shot = num_local_shots * i / par_shots; @@ -1155,7 +1154,7 @@ void Executor::measure_sampler(InputIterator first_meas, Utils::apply_omp_parallel_for((npar > 1), 0, npar, copy_samples_lambda, npar); - for (int_t i = 0; i < npar; i++) { + for (uint_t i = 0; i < npar; i++) { result.combine(std::move(par_results[i])); } } diff --git a/src/simulators/density_matrix/densitymatrix_executor.hpp b/src/simulators/density_matrix/densitymatrix_executor.hpp index b6bdb67146..7a3cece40d 100644 --- a/src/simulators/density_matrix/densitymatrix_executor.hpp +++ b/src/simulators/density_matrix/densitymatrix_executor.hpp @@ -1328,8 +1328,8 @@ Executor::sample_measure(const reg_t &qubits, uint_t shots, npar = local_samples.size(); std::vector all_samples(shots, SampleVector(qubits.size())); - auto convert_to_bit_lambda = [this, &local_samples, &all_samples, shots, - qubits, npar](int_t i) { + auto convert_to_bit_lambda = [&local_samples, &all_samples, qubits, + npar](int_t i) { uint_t ishot, iend; ishot = local_samples.size() * i / npar; iend = local_samples.size() * (i + 1) / npar; diff --git a/src/simulators/density_matrix/densitymatrix_state.hpp b/src/simulators/density_matrix/densitymatrix_state.hpp index 7210561a32..107cb69371 100644 --- a/src/simulators/density_matrix/densitymatrix_state.hpp +++ b/src/simulators/density_matrix/densitymatrix_state.hpp @@ -1008,8 +1008,8 @@ std::vector State::sample_measure(const reg_t &qubits, npar = shots; std::vector all_samples(shots, SampleVector(qubits.size())); - auto convert_to_bit_lambda = [this, &allbit_samples, &all_samples, shots, - qubits, npar](int_t i) { + auto convert_to_bit_lambda = [&allbit_samples, &all_samples, shots, qubits, + npar](int_t i) { uint_t ishot, iend; ishot = shots * i / npar; iend = shots * (i + 1) / npar; diff --git a/src/simulators/matrix_product_state/svd.cpp b/src/simulators/matrix_product_state/svd.cpp index 150d97af4f..f514b46674 100644 --- a/src/simulators/matrix_product_state/svd.cpp +++ b/src/simulators/matrix_product_state/svd.cpp @@ -632,7 +632,7 @@ void lapack_csvd_wrapper(cmatrix_t &A, cmatrix_t &U, rvector_t &S, zgesdd_("A", &m, &n, lapackA, &m, lapackS, lapackU, &m, lapackV, &n, work_, &lwork, rwork, iwork, &info); - delete iwork; + delete[] iwork; free(rwork); free(work_); } else { @@ -647,7 +647,7 @@ void lapack_csvd_wrapper(cmatrix_t &A, cmatrix_t &U, rvector_t &S, V = cmatrix_t::move_from_buffer(n, n, lapackV); S.clear(); - for (int i = 0; i < min_dim; i++) + for (size_t i = 0; i < min_dim; i++) S.push_back(lapackS[i]); // Activated by default as requested in the PR @@ -655,8 +655,8 @@ void lapack_csvd_wrapper(cmatrix_t &A, cmatrix_t &U, rvector_t &S, validate_SVdD_result(tempA, U, S, V); // #endif - delete lapackS; - delete work; + delete[] lapackS; + delete[] work; if (info == 0) { return; diff --git a/src/simulators/parallel_state_executor.hpp b/src/simulators/parallel_state_executor.hpp index 0635da9ef5..030f92456a 100644 --- a/src/simulators/parallel_state_executor.hpp +++ b/src/simulators/parallel_state_executor.hpp @@ -706,7 +706,7 @@ void ParallelStateExecutor::measure_sampler(InputIterator first_meas, Utils::apply_omp_parallel_for((npar > 1), 0, npar, copy_samples_lambda, npar); - for (int_t i = 0; i < npar; i++) { + for (uint_t i = 0; i < npar; i++) { result.combine(std::move(par_results[i])); } } diff --git a/src/simulators/shot_branching.hpp b/src/simulators/shot_branching.hpp index ab6805ec25..f42fad6925 100644 --- a/src/simulators/shot_branching.hpp +++ b/src/simulators/shot_branching.hpp @@ -374,7 +374,7 @@ bool Branch::apply_runtime_noise_sampling(const ClassicalRegister &creg, void Branch::remove_empty_branches(void) { // find first branch that has at least one shot - int_t iroot = -1; + uint_t iroot = 0; for (uint_t j = 0; j < branches_.size(); j++) { if (branches_[j]->num_shots() > 0) { iroot = j; diff --git a/src/simulators/stabilizer/clifford.hpp b/src/simulators/stabilizer/clifford.hpp index 568413d810..abe6cef15c 100644 --- a/src/simulators/stabilizer/clifford.hpp +++ b/src/simulators/stabilizer/clifford.hpp @@ -575,8 +575,8 @@ bool Clifford::measure_and_update(const uint64_t qubit, uint_t exponent_h = 0; auto measure_determinisitic_func = - [this, &accum, &exponent_l, &exponent_lc, &exponent_h, blocks, - blockSize, destabilizer_mask, ii](AER::int_t qq) { + [this, &accum, &exponent_l, &exponent_lc, &exponent_h, blockSize, + destabilizer_mask, ii](AER::int_t qq) { uint_t qs = qq * blockSize; uint_t qe = qs + blockSize; if (qe > num_qubits_) diff --git a/src/simulators/stabilizer/stabilizer_state.hpp b/src/simulators/stabilizer/stabilizer_state.hpp index cd0e18f678..85347fd775 100644 --- a/src/simulators/stabilizer/stabilizer_state.hpp +++ b/src/simulators/stabilizer/stabilizer_state.hpp @@ -518,7 +518,7 @@ std::vector State::sample_measure(const reg_t &qubits, // table auto qreg_cache = BaseState::qreg_; std::vector samples(shots); - for (int_t ishot = 0; ishot < shots; ishot++) { + for (uint_t ishot = 0; ishot < shots; ishot++) { samples[ishot].from_vector(apply_measure_and_update(qubits, rng)); BaseState::qreg_ = qreg_cache; // restore pre-measurement data from cache } diff --git a/src/simulators/statevector/statevector_executor.hpp b/src/simulators/statevector/statevector_executor.hpp index 26b00e801e..a9afef6489 100644 --- a/src/simulators/statevector/statevector_executor.hpp +++ b/src/simulators/statevector/statevector_executor.hpp @@ -607,8 +607,7 @@ double Executor::expval_pauli(const reg_t &qubits, const uint_t mask_u = ~((1ull << (x_max + 1)) - 1); const uint_t mask_l = (1ull << x_max) - 1; if (on_same_process) { - auto apply_expval_pauli_chunk = [this, x_mask, z_mask, x_max, mask_u, - mask_l, qubits_in_chunk, + auto apply_expval_pauli_chunk = [this, x_mask, z_mask, qubits_in_chunk, pauli_in_chunk, phase](int_t iGroup) { double expval_t = 0.0; for (uint_t iChunk = Base::top_state_of_group_[iGroup]; @@ -1246,8 +1245,8 @@ Executor::sample_measure(const reg_t &qubits, uint_t shots, npar = local_samples.size(); std::vector all_samples(shots, SampleVector(qubits.size())); - auto convert_to_bit_lambda = [this, &local_samples, &all_samples, shots, - qubits, npar](int_t i) { + auto convert_to_bit_lambda = [&local_samples, &all_samples, qubits, + npar](int_t i) { uint_t ishot, iend; ishot = local_samples.size() * i / npar; iend = local_samples.size() * (i + 1) / npar; diff --git a/src/simulators/statevector/statevector_state.hpp b/src/simulators/statevector/statevector_state.hpp index 4cccabc5a8..455ace2f7b 100755 --- a/src/simulators/statevector/statevector_state.hpp +++ b/src/simulators/statevector/statevector_state.hpp @@ -1043,8 +1043,8 @@ std::vector State::sample_measure(const reg_t &qubits, npar = shots; std::vector all_samples(shots, SampleVector(qubits.size())); - auto convert_to_bit_lambda = [this, &allbit_samples, &all_samples, shots, - qubits, npar](int_t i) { + auto convert_to_bit_lambda = [&allbit_samples, &all_samples, shots, qubits, + npar](int_t i) { uint_t ishot, iend; ishot = shots * i / npar; iend = shots * (i + 1) / npar; diff --git a/src/transpile/fusion.hpp b/src/transpile/fusion.hpp index 9948c640dc..758bacd167 100644 --- a/src/transpile/fusion.hpp +++ b/src/transpile/fusion.hpp @@ -330,6 +330,8 @@ class Fuser { const std::vector &fusioned_ops_idxs, const FusionMethod &method, const bool diagonal = false) const; + + virtual ~Fuser() = default; }; void Fuser::allocate_new_operation(oplist_t &ops, const uint_t idx, @@ -360,6 +362,7 @@ class CostBasedFusion : public Fuser { const int fusion_end, const uint_t max_fused_qubits, const FusionMethod &method) const override; + virtual ~CostBasedFusion() = default; private: bool is_diagonal(const oplist_t &ops, const uint_t from, @@ -392,6 +395,7 @@ class NQubitFusion : public Fuser { bool exclude_escaped_qubits(std::vector &fusing_qubits, const op_t &tgt_op) const; + virtual ~NQubitFusion() = default; private: bool active = true;