Linux and aliasing?

Jamie Lokier egcs@tantalophile.demon.co.uk
Sat Jun 5 12:41:00 GMT 1999


mark@codesourcery.com suggests:

>   Put expressions of the form `*((foo*) (&x))' in alias set zero if
>   x does not have type foo, or one of the types that is allowed
>   to alias it.
> 
> This proposal only affects nonconforming code, and thus changing the
> behavior of the compiler will not pessimize any conforming code.

I don't like this because it's not what we do in C++.
In C++ when we want to do these naughty things, we used to do:

  *(foo*)(void*)(&x)

I bet there's still a fair bit of that around.
In the modern world we've got *reinterpret_cast<foo*>(&x), which
is presumably treated specially w.r.t. aliases.

[Could someone tell me if reinterpret_cast does the right thing with
aliases please?]

thanks,
-- Jamie


More information about the Gcc mailing list