ISO Aliasing rules question

Michael Matz matz@suse.de
Fri Feb 21 20:29:00 GMT 2003


Hi,

On Fri, 21 Feb 2003, Mark Mitchell wrote:

> --On Friday, February 21, 2003 08:38:07 PM +0100 Michael Matz
> <matz@suse.de> wrote:
>
> > Yes, but he's accessing a member, not the whole struct.  And that access
>
> I'm pretty sure it's the pointer he's using that's the key.
>
> If he wrote:
>
>   double *dp = (double*) b;
>
>   *dp = 1.0;
>
> that would be fine, but saying b->d = 1.0 isn't.

Hmm.  How's that then:

double *dp = &(b->d);
*dp = 1.0;

This definitely is accessing a 'double' object, and aliases ergo with
a->d.  In this regard I fail to see the difference between
"*dp = 1.0" and "b->d = 1.0".  If there _is_ a difference it could only
result from types, and then only if there would be the concept of
subtypes, or tagged types, or however we call them.  I.e. if
type(*dp) != type(b->d) would be true.  I don't think this concept exists
in C.  Hmm.


Ciao,
Michael.



More information about the Gcc mailing list