prinzdezibel prinzdezibel - 1 month ago 23
C Question

C/C++ Free alternative to Lint?

I'm interested in a free tool that can statically check my C++ code like Lint does.
Any hints?

Answer

Try cppcheck, found here: http://cppcheck.sourceforge.net/

Here's a sampling of some of the checks it can perform or that I've used it for:

  • Array indices out of bounds
  • Memory/resource leaks
  • Improper new/delete
  • Failure to put virtual destructors on derived classes
  • Mismatching allocation and deallocation
  • Deallocating a deallocated pointer
  • Using variable after it is deallocated / released
  • Size mismatches
  • Invalid radix in call to strtol or strtoul
  • Overlapping data buffers
  • Unsigned division; result may be wrong
  • Unusual pointer arithmetic
  • Returning pointer to local array variable
  • Same iterator is used with two containers
  • Dangerous usage of erase
  • After pushback or pushfront, iterator may be invalid
  • Buffer overruns
  • Dangerous usage of strncat, possible buffer overrun
Comments