View Full Version : Static Analysis to Find Bugs

03-17-2012, 02:26 PM
I was surprised to find progress being made on iADOM. The iADOM "team" may want to consider using the static analysis Xcode provides to find bugs. [Product -> Analyze] The static analysis is complaining about things in the LUA source files in my project. It will probably find a boatload of wild and "wonderful" things in the ADOM source code.

03-17-2012, 05:32 PM
Thanks for the tip! I'm aware of the static analysis in Xcode and I've been using on the ADOM sources. I don't think it found anything critical in ADOM. But every port to a new operating system or switch to a different compiler resulted in the discovery of one or more problems, that we're undiscovered before.

03-18-2012, 03:14 AM
The nice thing about the static analysis is that it should find a lot of the universal bugs that live in the portable portion of your code base. The static analysis is not perfect though. It can and will complain about tricky coding practices like the crazy pointer stuff some people do (probably a good thing). It will also complain about some coding practices that enhance maintainability or readability but serve no purpose in the program. For example:

void my_function() {
int offset = 0;
offset = do_something_a();
offset = do_something_b();
offset = do_something_c(); // complains that the last value stored in 'offset' is never read
}Also, can click on the analysis warning to get a step by step walkthrough of the perceived problem. Good luck!