🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #2762

Re: Unspecified, not undefined

#2762
From: Jonathan Gingerich
Date: Wed, 17 Apr 1991 20:51
52 lines
1563 bytes
In article <RJOHNSON.91Apr17102824@olorin.shell.com> 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.
Technical Details
Message-ID: <1991Apr17.205139.22449@cs.ucla.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!ucla-cs!maui.cs.ucla.edu!jon
References: <RJOHNSON.91Apr17102824@olorin.shell.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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: <RJOHNSON.91Apr17102824@olorin.shell.com>
Sender: usenet@cs.ucla.edu (Mr. News Himself)
Distribution: comp
Organization: UCLA Computer Science Department
Lines: 52
Nntp-Posting-Host: maui.cs.ucla.edu