Kaz Kylheku skrev:
> > Is there any free, or close-to-free, tool that you can recommend?
>
> The GNU compiler has a lot of C++ specific warnings which are not turned
> on by default. It's not exactly lint, but you can squeeze more out of
> the compiler's diagnostic ability
This lack of checking tools has bothered me too. Therefore I was
delighted when I read at [http://freshmeat.net/projects/gcc/] that "GCC
provides many levels of source code error checking traditionally
provided by other tools (such as lint)". But unfortunately this is not
what GCC is trying to be. If I report a feature request for a checking
feature, it is usually rejected within half an hour.
For example there is a useful feature in the Ada frontend, that warns
about variables that are not modified after initialization and could be
declared constant (with "gnatmake -gnatwa"). This feature has helped me
catch a few errors, for example when I intended to modify a variable and
then forgot to write the statement to do it. Now some people probably
say that I should be using Ada instead of C++ anyway. In principle they
are right of course, but unfortunately I still often have to code in C++
(for existing projects). So I requested to have this useful feature for
C++ as well. The request got closed as WONTFIX and someone replied
"Isn't this a task for lint-like tool? GCC isn't such thing." I wonder
why we can not make C++ development at least a LITTLE bit easier and
safer by adding such features. It wouldn't be Ada, but it would
certainly help during the time while we still have to use C++.
[http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25845]
Another feature request was to warn about using pointers without
checking for 0 (which would result in segmentation fault). That request
went the same way. [http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29208]
Sure, C++ was not designed to control nuclear power plants or space
shuttles, but does that mean we are not allowed to avoid bugs when we
can easily do so?