Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!batcomputer!munnari.oz.au!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Re: Can analysis detect undefined expressions? Message-ID: <6371@goanna.cs.rmit.oz.au> Date: 17 Jun 91 12:36:36 GMT References: <14206.285B7688@stjhmc.fidonet.org> Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 25 In article <14206.285B7688@stjhmc.fidonet.org>, Dave.Harris@f14.n15.z1.fidonet.org (Dave Harris) writes: > An extended example so that I can think clearly here: > > (j = ((i=1) == (i=2))) == (j = ((i=3) == (i=4))) > > Assumedly, i can end up as 1,2,3, or 4. j should be 0. The grouping is such > that i=4, i=2, i=3, i=1 won't happen without breaking any laws. right? Wrong. Think of the assignments as going into a bag. By the time you reach a "sequence point" all of the assignments must have been pulled out of the bag and been done, but they can be pulled out of the bag in any order. So ((i=1) == (i=2)) => put into bag put into bag (j = ...) => put into bag ((i=3) == (i=4)) => put into bag put into bag (j = ...) => put into bag So now we can pull the assignments out in any order we please; 4 -> i, 2 -> i, 3 -> i, 1 -> i, 0 -> j, 0 -> j is perfectly possible. This can be optimised if i, j are not volatile. -- Q: What should I know about quicksort? A: That it is *slow*. Q: When should I use it? A: When you have only 256 words of main storage.