Is there any sort of tool out there that can warn about code that can<digression>
behave differently depending on "unspecified" behaviour? For instance,
take the following statement:
*p++ = ConvertToLowercase(*p);
That's not just unspecified, it's undefined: It both modifies `p'
and reads it (for a purpose other than computing the new value),
without a sequence point between the two accesses.
There's a sequence point between the evaluation of `*p' and the
invocation of ConvertToLowercase(), and there's another sequence
point just before the function returns (if the function is written
in C), but that doesn't mean that there's a sequence point between
the two uses of `p'.
</digression>
[...]Your compilers may be able to diagnose some of them, if you crank
Is there any sort of tool that can go through code and warn about
instances in which "unspecified" behaviour can result in two or more
different behaviours?
their diagnostic sensitivities high enough. There's also "lint," which
(like "cc") comes in a lot of flavors with varying capabilities, in
both commercial and non-commercial versions. I don't know which lints
will and won't catch this sort of thing, but that's the place to start
your search.
--
Er*********@sun.com