This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH: `__norestrict' type qualifier
Jamie Lokier <egcs@tantalophile.demon.co.uk> writes:
|> Andreas Schwab wrote:
|> > |> short s = 5;
|> > |> long *pl;
|> > |> short *ps;
|> > |> pl = &s;
|> > |> ps = (short *)pl;
|> >
|> > The second last line contains a constraint violation (assignment of
|> > incompatible pointer types), so anything can happen. But if you add the
|> > required cast then "ps == &s" must be true afterwards.
|>
|> Really? So Chip's point about word-addressed machines having different
|> sizeof (long *) and sizeof (char *) is totally wrong then?
I was wrong. If pl is not correctly aligned for a long then the behaviour
is undefined.
>From C9x, 6.3.2.3 Pointers
[#7] A pointer to an object or incomplete type may be
converted to a pointer to a different object or incomplete
type. If the resulting pointer is not correctly aligned50)
for the pointed-to type, the behavior is undefined.
Otherwise, when converted back again, the result shall
compare equal to the original pointer.
Andreas.
--
Andreas Schwab "And now for something
schwab@suse.de completely different."
SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg