On 2010-01-05 15:30:11 +0000, Joseph S. Myers wrote:
> On Tue, 5 Jan 2010, Vincent Lefevre wrote:
>
> > On 2010-01-05 10:31:13 +0000, Andrew Haley wrote:
> > > "An object shall have its stored value accessed only by an lvalue
> > > expression that has one of the following types:
> > >
> > > but
> > >
> > > (union u*)&i
> > >
> > > is not a legal lvalue expression because the dereference is undefined
> > > behaviour. You may only dereference a pointer as permitted by 6.3.2.3.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > For the same reason, (char *) &i could not be dereferenced, and this
> > would break a lot of code!
>
> No, read 6.3.2.3 again. Specifically, where it says "When a pointer to an
> object is converted to a pointer to a character type, the result points to
> the lowest addressed byte of the object. Successive increments of the
> result, up to the size of the object, yield pointers to the remaining
> bytes of the object.".
6.3.2.3 says that one can *convert* the pointer, but not that one can
*dereference* it.
--
Vincent Lefèvre <[email protected]> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)