By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,631 Members | 1,144 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,631 IT Pros & Developers. It's quick & easy.

Re: Warn about unspecified behaviour

P: n/a
Tomás Ó hÉilidhe wrote:
Is there any sort of tool out there that can warn about code that can
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'.

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?
Your compilers may be able to diagnose some of them, if you crank
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.

Jul 23 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.