home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.std.c
- Path: sparky!uunet!decwrl!twwells!bill
- From: bill@twwells.com (T. William Wells)
- Subject: Re: void expressions and volatile types
- Date: Wed, 16 Sep 1992 00:40:51 GMT
- Message-ID: <BunB85.Drq@twwells.com>
- References: <BtnI48.D9I@twwells.com> <1992Sep07.104043.19879@x.co.uk>
- Organization: None, Mt. Laurel, NJ
- Lines: 32
-
- > Here's the mistake. The value of the expression can be obtained by
- > remembering the value stored into a - it is not necessary to re-fetch
- > it, even though a is volatile.
-
- Wrong. The standard is quite clear: the value of the result is the
- *value of the left operand after the assignment*. It is *not* the
- value stored into the left operand. In the case of non-volatiles,
- this makes no difference. In the case of volatiles this *requires*
- an access to the variable to obtain the value.
-
- > The storing of a value into a is a side-effect, and so takes place
- > sometime before the next sequence point. Any other change that takes
- > place to a (e.g. because it is a memory-mapped device) between the same
- > pair of sequence points counts as a double assignment, and is therefore
- > undefined, and therefore the implementation can do what it wants
- > (including not reading a after storing).
-
- Wrong again. The relevant section says *stores by an expression*
- thus explicitly excluding stores from other sources.
-
- So the question stands: does an assign to a volatile in the
- context of a void expression require an additional load to obtain
- the value? Or may "discard" be interpreted to mean "not obtain"?
- The former requires an additional load of the volatile in order
- to obtain the value; the second does not. At the moment, my
- compiler does not generate the additional load because otherwise
- writing device drivers would be almost impossible. But I'd really
- like to see an *INFORMED* opinion on this.
-
- ---
- Bill { uunet | decwrl | telesci }!twwells!bill
- bill@twwells.com
-