Skip to content

Commit

Permalink
Systematically fix CodeQL warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
WrathfulSpatula committed Nov 21, 2024
1 parent eb396fa commit a3d9854
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/common/qrack_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,17 @@

#if QBCAPPOW < 6
#define bitCapInt uint32_t
#define QRACK_MAX_QUBITS 32
#elif QBCAPPOW < 7
#define bitCapInt uint64_t
#define QRACK_MAX_QUBITS 64
#elif (QBCAPPOW < 8) && defined(__SIZEOF_INT128__)
#define bitCapInt unsigned __int128
#define QRACK_MAX_QUBITS 128
#else
#include "big_integer.hpp"
#define bitCapInt BigInteger
constexpr size_t QRACK_MAX_QUBITS = (1 << QBCAPPOW);
#endif

#if FPPOW < 5
Expand Down
5 changes: 5 additions & 0 deletions src/qinterface/qinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ QInterface::QInterface(
, rand_distribution(ZERO_R1_F, ONE_R1_F)
, hardware_rand_generator(NULL)
{
if (qubitCount > QRACK_MAX_QUBITS) {
throw std::invalid_argument(
"Requested QInterface qubit count is larger than the limits of the current Qrack build options!");
}

#if ENABLE_RDRAND || ENABLE_RNDFILE || ENABLE_DEVRAND
if (useHardwareRNG) {
hardware_rand_generator = std::make_shared<RdRandom>();
Expand Down

0 comments on commit a3d9854

Please sign in to comment.