*devaddr = 0 and volatile

Doug Gwyn gwyn at smoke.BRL.MIL
Wed Dec 7 03:13:46 AEST 1988


In article <23706 at amdcad.AMD.COM> tim at crackle.amd.com (Tim Olson) writes:
>I was speaking to Richard Relph about this subject, and he brought up
>the problem of unaligned accesses through a pointer to a volatile object
>which is larger than a char, but is not properly aligned [what a
>mouthful!].  These also require multiple accesses to be performed
>"correctly."  What should be done here?

You're already in the realm of entirely implementation-dependent behavior.
There is no way to obtain via pure C constructs such a pointer along with
a guarantee that it can be used to access something.  I would recommend
that the implementation warn about the attempted misaligned access in such
a case, IF it can readily determine that this is being attempted.  Whether
it should generate code to access the object piece by piece is debatable;
it's not required by the Standard and would impose a large burden to
support in most implementations.

"volatile" really is not an issue here.  Sequential access of multiple
portions of an object does not violate the requirements of the Standard
(section 2.1.2.3).  For objects specified as "volatile", failure to
access or multiple accesses -- when not specified as such for the
abstract machine in the source code -- would be a violation.

P.S. The above is my own interpretation, not necessarily X3J11's.



More information about the Comp.lang.c mailing list