From mboxrd@z Thu Jan 1 00:00:00 1970 From: Fergus Henderson To: Alexandre Oliva Cc: Axel Kittenberger , gcc@gcc.gnu.org Subject: Re: Is this a gcc bug? Date: Fri, 12 Jan 2001 19:11:00 -0000 Message-id: <20010113141053.B30713@hg.cs.mu.oz.au> References: <11420.979291083@www27.gmx.net> X-SW-Source: 2001-01/msg00843.html On 13-Jan-2001, Alexandre Oliva wrote: > On Jan 12, 2001, Axel Kittenberger wrote: > > > bug.i:8: unpredictable behaviour due to undefined evaluation sequence of > > 'x' > > It's the behavior that is undefined. How about: > > undefined behavior: expression may modify `x' multiple times You also get the warning for cases like printf("%d %d\n", x++, x); where cause of the undefined behaviour is not that `x' was modified multiple times, but that `x' was both modified and read. The warning that you suggest would not be appropriate in these cases. It might be good to give different warnings for these two different kinds of problems, depending on whether they violate the first sentence of C99 6.5 #2, or the second: | Between the previous and next sequence point an object | shall have its stored value modified at most once by the | evaluation of an expression. Furthermore, the prior value | shall be read only to determine the value to be stored.70) For those that violate the first sentence, your suggested warning sounds OK. But for those that violate the second, something like warning: undefined behavior: expression modifies `x' and reads `x' would be better. -- Fergus Henderson | "I have always known that the pursuit | of excellence is a lethal habit" WWW: < http://www.cs.mu.oz.au/~fjh > | -- the last words of T. S. Garp.