Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!uflorida!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: *devaddr = 0 and volatile Message-ID: <9085@smoke.BRL.MIL> Date: 6 Dec 88 17:13:46 GMT References: <674@quintus.UUCP> <117@halcdc.UUCP> <468@auspex.UUCP> <13784@oberon.USC.EDU> <14832@mimsy.UUCP> <9059@smoke.BRL.MIL> <21686@apple.Apple.COM> <23706@amdcad.AMD.COM> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB)) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 23 In article <23706@amdcad.AMD.COM> tim@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.