example: #include <stdexcept> #include <cstdio> void testit (bool throw_p){ if (throw_p) throw std::runtime_error("test"); } void test1(){ std::puts("test1"); { testit(false); } try { testit(true); } catch (const std::runtime_error& e){ std::puts("caught exception:"); std::puts(e.what()); } } int main(){ test1(); return 0; } the code runs and produces output: test1 caught exception: test i.e. the exception is caught inside the test function as it should be. However, cppcheck 2.19.1 reports: athena/test.cxx:23:3:...
Hi, I have recently switched to cppcheck 2.18 for our project (which is large, ~4 million lines of code) and I am finding that depite using the "--cppcheck-build-dir=quickcpp" option, the build directory is completely rewritten every time. My full command is below: ~/cppcheck-2.18.0/build/bin/cppcheck -j16 --std=c++20 --enable=warning,performance,portability --inline-suppr -D__CPPCHECK__ --suppress-xml=suppressions.xml -iCudaFitter.cpp -itest --cppcheck-build-dir=quickcpp --library=Athena.xml --xml-version=2...
Hi, I have recently switched to cppcheck 2.18 for our project (which is large, ~4 million lines of code) and I am finding that depite using the "--cppcheck-build-dir=quickcpp" optiion, the build directory is completely rewritten every time. My full command is below: cd ~ && ~/cppcheck-2.18.0/build/bin/cppcheck -j16 --std=c++20 --enable=warning,performance,portability --inline-suppr -D__CPPCHECK__ --suppress-xml=suppressions.xml -iCudaFitter.cpp -itest --cppcheck-build-dir=quickcpp --library=Athena.xml...
False positive for array index out-of-bounds when dealing with postincremented index on an array of functions, e.g. #include <iostream> #include <array> #include <functional> int main(int argc, const char * argv[]) { unsigned roiElementNumber = 0; // std::array<std::function<int(const int)>,2> fillResultFunctors={ [&](const int n) { return n;}, [&](const int n) { return 100+n; } }; constexpr std::array<int,3> a{1,2,3}; //cppcheck gives false containerOutOfBounds error for(const auto i:a) { if (roiElementNumber...
False positive for array index out-of-bounds when dealing with postincremented index on an array of functions, e.g. #include <iostream> #include <array> #include <functional> int main(int argc, const char * argv[]) { unsigned roiElementNumber = 0; // std::array<std::function<int(const int)>,2> fillResultFunctors={ [&](const int n) { return n;}, [&](const int n) { return 100+n; } }; constexpr std::array<int,3> a{1,2,3}; //cppcheck gives false containerOutOfBounds error for(const auto i:a) { if (roiElementNumber...
Environment is centos7; we habitually use gcc 11.2 compiler with c++ 17 std.
Running cppcheck 2.10 on the following code produces "Internal Error. MathLib::toLongNumber: input was not completely consumed: 2_Tesla [cppcheckError]" #include <iostream> constexpr double operator"" _Tesla ( unsigned long long b ){ return b*10000.; } int main(){ const double f=2_Tesla; std::cout<<f<<std::endl; return 0; }
Thanks, just giving a spin now. One new error I'm seeing is "cppcheckError" which I guess is internal, as a result of using user-defined suffices, it seems. : "cppcheckError error Internal Error. MathLib::toLongNumber: input was not completely consumed: 1_GeV"