Interpretation of volatile - two questions

Dave Gillespie daveg at near.cs.caltech.edu
Thu Mar 22 14:30:32 AEST 1990


> In article <2604A628.8521 at paris.ics.uci.edu> rfg at paris.ics.uci.edu (Ronald Guilmette) writes:
>	struct s {
>		char		c1;
>		volatile char	c2;
>	};
>...
>		c = memory_mapped_device_p->c1;
>...
>does the standard (a) permit, (b) require, or (c) prohibit the assignment
>statement shown to access the c2 field of the "struct s" pointed to by
>memory_mapped_device_p?

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*.

								-- Dave
--
Dave Gillespie
  256-80 Caltech Pasadena CA USA 91125
  daveg at csvax.caltech.edu, ...!cit-vax!daveg



More information about the Comp.std.c mailing list