This code must have 3 mistakes:
First mistake: int numEntries. Later you do: ++numEntries;
You are incrementing the unspecified value. Not sure if it's the root cause, but still unacceptable.
Second and third mistake:
const int length = numEntries;
int* arr = new int[length];
const int size = numEntries;
Your numEntries has the unspecified value (first mistake). You are using it to initialize the length and size now this is Undefined Behaviour. Let us consider it is just some big number - you are allocating memory of unspecified size, So the std::bad_alloc exception - it means you are trying to allocate more memory than you have available.
Also the matrix is a VLA of unspecified size, which is both the non-standard and Undefined behaviour.