With the following code when there is failure to allocate memory std::bad_alloc is thrown. The following test of the pointer is useless. This is from C++ Gotchas P172. I think it would be worthwhile to catch this with CPPCheck.
int * ip = new int;
if (ip)
std::cout << "Always executed";
else
std::cout << "Never executed";
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
With the following code when there is failure to allocate memory std::bad_alloc is thrown. The following test of the pointer is useless. This is from C++ Gotchas P172. I think it would be worthwhile to catch this with CPPCheck.
int * ip = new int;
if (ip)
std::cout << "Always executed";
else
std::cout << "Never executed";
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/14991