CppCheck 1.67 defined and executed the array, gaining access to errors outside the boundaries of one of my projects. I did not think the code was wrong, so I split the code into a minimal example that still causes the same error. Why does CppCheck give the following error for the first C ++ example (inside the namespace), but not for the second example (without the namespace)?
Am I doing something wrong with the namespace in my array initialization or is it a bug in CppCheck?
Reported error: "Array" testArray [5] "accesses index 5, which is out of bounds."
namespace TestNamespace { class TestClass { static const int testArray[5]; }; const int TestClass::testArray[] = { 1, 2, 3, 4, 5}; }
No error reported:
class TestClass { static const int testArray[5]; }; const int TestClass::testArray[] = { 1, 2, 3, 4, 5};
source share