Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!ucla-cs!maui.cs.ucla.edu!jon From: jon@maui.cs.ucla.edu (Jonathan Gingerich) Newsgroups: comp.std.c Subject: Re: Unspecified, not undefined Message-ID: <1991Apr17.205139.22449@cs.ucla.edu> Date: 17 Apr 91 20:51:39 GMT References: Sender: usenet@cs.ucla.edu (Mr. News Himself) Distribution: comp Organization: UCLA Computer Science Department Lines: 52 Nntp-Posting-Host: maui.cs.ucla.edu In article rjohnson@shell.com (Roy Johnson) writes: >One more shot at this "problem": > >int v=1; > >int return_v() { > return v; >} > >int main() { > printf("v=%d, v=%d\n", v++, return_v()); > return 0; >} I don't believe the following sequence is prohibited: evaluation of (0) args to return_v() evaluation of return_v s.p. between evaluation of call and call evaluation of v++ - reads v side effect of v++ - writes v using previous read call to return_v() - reads v ... This would make it undefined. >Or how about using aliasing: > >int main() { > int v=1, *pv=&v; > > printf("v=%d, v=%d", v++, *pv); > return 0; >} Again, read and separated write of the same location would make it undefined, and there are no s.p.'s in question - undefined. I believe any unordered asymetric operation combined with function calls (not macros!-) can be unspecified. int v=1; int bump_v() { return ++v; } int main() { ... (bump_v() - bump_v()) ... } Jon.