Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!decwrl!pa.dec.com!decuac!grebyn!ckp From: ckp@grebyn.com (Checkpoint Technologies) Newsgroups: comp.lang.c Subject: Can analysis detect undefined expressions? Message-ID: <1991Jun13.015548.24724@grebyn.com> Date: 13 Jun 91 01:55:48 GMT Organization: Grebyn Timesharing Lines: 28 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@grebyn.com (Who needs a fancy .signature?)