Interpretation of volatile - two questions

Steve Hosgood iiitsh at cybaswan.UUCP
Wed Mar 21 19:55:29 AEST 1990


In article <1990Mar19.165931.22758 at utzoo.uucp> henry at utzoo.uucp (Henry Spencer) writes:
>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?
>
>The standard, by and large, is silent about the *details* of how volatile
>works.  Necessarily so; it's very machine-specific.  Suppose your machine's
>bus only does word accesses, and it *cannot* access c1 without also
>touching c2?

In this latter case, surely the 'expected' compiler action should be to
print an error message to the tune of 'cannot generate code on this machine'.
After all, it can't be right for a compiler to generate code that does
an invisible access to a volatile - even if it can't help it.

Steve



More information about the Comp.std.c mailing list