Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84; site dataioDataio.UUCP
Path: utzoo!watmath!clyde!cbosgd!ihnp4!houxm!vax135!cornell!uw-beaver!uw-june!entropy!dataio!bright
From: bright@dataioDataio.UUCP (Walter Bright)
Newsgroups: net.lang.c
Subject: Re: Type modifiers in C
Message-ID: <846@dataioDataio.UUCP>
Date: Mon, 28-Oct-85 16:33:07 EST
Article-I.D.: dataioDa.846
Posted: Mon Oct 28 16:33:07 1985
Date-Received: Wed, 30-Oct-85 04:59:03 EST
References: <943@lll-crg.ARpA>
Reply-To: bright@dataio.UUCP (Walter Bright
Organization: Data I/O Corp., Redmond WA
Lines: 40
Keywords: volatile const

In article <943@lll-crg.ARpA> brooks@lll-crg.ARpA (Eugene D. Brooks III) writes:
>Could someone explain all the details of what you might do with for example
>the volatile type modifier.  For instance does
>
>volatile int foo;	/* Mean that the int foo is volatile. */
 YES.

>int * volatile bar;	/* Mean that bar is a non volatile pointer
>			to a volatile int. */
 NO. Bar is a volatile pointer to a non-volatile int.

>int * volatile cat();	/* Mean that cat returns a pointer to a volatile int*/
 NO. Cat() returns a volatile pointer to an int.

>volatile int cat();	/* What does this mean? */
 Cat() returns a volatile int.

>volatile int * dog;	/* Mean that dog is a volatile pointer to a
>			non-volatile int. */
 Dog is a pointer to a volatile int.

>volatile int * volatile fly;	/* Mean a volatile pointer to a volatile int.*/
 YES.

The purpose of the volatile modifier is so that an optimizing compiler
can be told which variables are not candidates for common subexpression
elimination, which ones cannot be put in registers, and which ones are not
candidates for redundant load/store removal. Having a function return
a volatile is not an error, but it doesn't mean much (unless the compiler
is able to deduce that the function call is redundant!).
	My understanding of volatile is that it is a modifier and binds very
tightly. Whether it is left or right associative is not clear.
Such as:

	char * volatile * s;

	
		-OR-
	
		??