K
Keith Thompson
[...]Chris Hills said:Because a C compiler is a translator. Not an error checker. It tries to
make the most complex statement it can from the tokens.
For error checking use Lint. that is whit it is designed for.
A compiler is both a translator and an error checker. A conforming C
compiler is required by the standard to issue diagnostics for certain
classes of errors; the diagnostics aren't required to be useful, but
in any decent compiler they will be.
The decision to make lint a separate tool from the compiler is an old
historical one. I don't know much about what went into that decision,
but I suspect it had to do with resource limits on the machines of the
time, limits that are no longer relevant.
There are still various lint-like tools floating around, and it's
still a good idea to use them, but there's no inherent reason why the
compiler itself shouldn't be doing what lint does, at least
optionally. Most C compilers will issue warnings for perfectly legal
code; this is, in my opinion, a good thing. gcc, for example, will
warn about unused or potentially unitialized variables, incorrect
printf format strings, and a number of other things.