Interpretation of volatile - two questions

Ray Dunn ray at philmtl.philips.ca
Fri Mar 23 00:54:48 AEST 1990


In referenced article, daveg at near.cs.caltech.edu (Dave Gillespie) writes:
>Henry Spencer and Doug Gwyn point out that on a word-addressed machine
>it may not be possible to read c1 without touching c2 as well.  But it
>seems to me that compilers have the flexibility to pad out structures
>in order to avoid this---a compiler on such a machine could surround a
>volatile object with enough padding to keep it isolated.
>
>Even if the standard does not specify (c), it seems to me that it
>reasonably *could*.

Only having K&R II to work with I may be on the wrong track, but I don't see
the relevance here to volatile.

Surely volatile only ensures that no references to the qualified variables
are optimized *out*, not that no hidden references are created.  Is there
*any* mention of the latter?

I don't believe it's the job of the compiler to give such assurances other
than that no reference will be optimized out.

The programmers' requirements in these cases are so machine dependant, and
*application* dependant, that the compiler could never be expected to modify
it's behaviour in the required best way.  A cross compiler for a particular
micro-processor has *no* knowledge about the architecture (memory and I/O
for example) that the compiled code will be running in.  These
considerations must always be left up to the programmer to handle.
-- 
Ray Dunn.                    | UUCP: ray at philmtl.philips.ca
Philips Electronics Ltd.     |       ..!{uunet|philapd|philabs}!philmtl!ray
600 Dr Frederik Philips Blvd | TEL : (514) 744-8200  Ext : 2347 (Phonemail)
St Laurent. Quebec.  H4M 2S9 | FAX : (514) 744-6455  TLX : 05-824090



More information about the Comp.std.c mailing list