Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site rabbit.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!allegra!alice!rabbit!mjs
From: mjs@rabbit.UUCP (M. J. Shannon, Jr.)
Newsgroups: net.lang.c
Subject: Re: ANSI C, optimization, `volatile' declarations
Message-ID: <3237@rabbit.UUCP>
Date: Sun, 14-Oct-84 22:11:14 EDT
Article-I.D.: rabbit.3237
Posted: Sun Oct 14 22:11:14 1984
Date-Received: Tue, 16-Oct-84 03:10:48 EDT
References: <1538@wateng.UUCP>, <4453@utzoo.UUCP>
Organization: AT&T Bell Laboratories, Murray Hill
Lines: 38



> > [Compiler is optimizing out a wait-for-hardware-done loop.]
> > ...
> > 1.  Was this legal code generation?
> > 2.  Note that this compiler did "simple" optimizations as part of the code
> > 	generation. Is this legal?
> 
> As to whether it's legal by K&R, the only answer is "mumble".  This
> thorny issue was never addressed in the old days.  The draft ANSI standard
> has a "volatile" declaration that you can use to tell the compiler "don't
> get tricky with this variable, it may change underfoot".

First, I'd like to point out that the name of the standards organization
is ANSI: American National Standards Institute.  The name is unrelated to
the name of the character set most of us are using (ASCII: American
Standard Code for Information Interchange).  Now, with that out of the
way....

Ok, given the `volatile' keyword, what are its semantics?  If (on System V)
I have pointers into memory that is shared by other processes, must I
declare them `volatile struct foo *' and have the compiler deduce that all
members of such a structure are volatile (my opinion of correct behavior)?
Further, if the structure so referenced has pointers in it, are they
assumed to be volatile or non-volatile?  If my program manages linked lists
in shared memory, must the forward and backward pointers also be declared
volatile?  If so, this means that I may suffer from non-optimization of
linked lists (identically declared) in non-shared memory.  Volatility
declarations are very tricky in a language such as C!

Is a current draft available (sorry, I haven't been following this
discussion due to (what seems to me to be) an inordinate amount of
drivel)?  If so, how may I obtain it?
-- 
	Marty Shannon
UUCP:	{alice,rabbit,research}!mjs
	(rabbit is soon to die.  Does this mean alice is pregnant?  Yup!)
Phone:	201-582-3199