- Matt Love, Software Development Manager
I'd like to share an interesting discovery that Parasoft's own Jtest development team made recently: a static analysis rule for optimization actually alerted us to a serious defect
We wanted to optimize our code base before the next release, so we extended our usual static analysis configuration to include several optimization rules. One rule (OPT.LIOL) recommended moving aResults[0] outside and above the loop as an optimization for the following Java code:
for (int i = 0; I < aResults.length; i++) {
ICodingStandardsCoverageInfo coverageInfo =
(ICodingStandardsCoverageInfo)aResults[0];
updateStatistics(coverageInfo);
}
Blindly following the rule would indeed optimize this code. But a closer look at this code revealed that using array index 0 for every loop iteration was a mistake and a functional error.
The same defect pattern also exists in other languages with loop constructs, and it may be detected with rules in Parasoft C++test (for C and C++) and Parasoft .TEST (for .NET code - including C#, VB.NET, ASP.NET and Managed C++).
Friday, April 30, 2010
Subscribe to:
Comments (Atom)
