Can analysis detect undefined expressions?

Checkpoint Technologies ckp at grebyn.com
Thu Jun 13 11:55:48 AEST 1991


The subject line is not very good.  Let me explain what I want.

Some expressions in C are undefined, because of expression reordering and
side effects. A recent (ongoing?) thread discussed the possible different
interpretations of if ((i=1) == (i=2)), and there are other examples like
i = i++ + i++, and so on.

I'd like to know if there has been any attempt to diagnose such undefined
expressions.  It seems like an exceedingly difficult thing to do,
especially considering aliasing and possible side effects of functions.

I have two reasons for asking. One is that I'm sure everyone would love
to have the compiler (or lint) point out these errors, and so we'd all
create bug-free code.  :-)

Another reason is that I have a similar problem in another language,
which I'm trying to re-implement. This language is supposed to be
a specification language which is insensitive to the order in which it's
primitives are evaluated. Well, 95% of the time is is, but we have to
explain to users how to avoid problems in those last 5% of cases.
So I'm exploring the idea of providing diagnostics for these exceptional
cases. I figure if someone's done it for C expressions then the same
concepts should apply to this other language.

Any ideas? Has it been proven impossible? Thanks all.
-- 
Richard Krehbiel, private citizen      ckp at grebyn.com
(Who needs a fancy .signature?)



More information about the Comp.lang.c mailing list