Check array size is not zero after resize

This commit is contained in:
Tom Deakin 2015-07-29 16:06:18 +01:00
parent d463c036b1
commit d02bb84b9f
3 changed files with 10 additions and 0 deletions

View File

@ -33,6 +33,14 @@ struct badntimes : public std::exception
}
};
struct badarraysize : public std::exception
{
virtual const char * what () const throw ()
{
return "Array size must be >= 1024";
}
};
template < typename T >
void check_solution(void* a_in, void* b_in, void* c_in)
{

View File

@ -81,6 +81,7 @@ int main(int argc, char *argv[])
<< "Warning: array size must divide 1024" << std::endl
<< "Resizing array from " << OLD_ARRAY_SIZE
<< " to " << ARRAY_SIZE << std::endl;
if (ARRAY_SIZE == 0) throw badarraysize();
}
// Get precision (used to reset later)

View File

@ -65,6 +65,7 @@ int main(int argc, char *argv[])
<< "Warning: array size must divide 1024" << std::endl
<< "Resizing array from " << OLD_ARRAY_SIZE
<< " to " << ARRAY_SIZE << std::endl;
if (ARRAY_SIZE == 0) throw badarraysize();
}
// Get precision (used to reset later)