Linux and aliasing?

mark@codesourcery.com mark@codesourcery.com
Sat Jun 5 16:53:00 GMT 1999


>>>>> "Jamie" == Jamie Lokier <egcs@tantalophile.demon.co.uk> writes:

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

    Jamie>   *(foo*)(void*)(&x)

I intended this to be covered by my proposal.  This would officially
be a "funny cast", and considered able to alias anything, provided
that x is a variable of an expression of the form a->b or a.b.

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

No, it does not.  The use of reinterpret_cast does not exempt a
standard-conforming program from the rules about using an lvalue of
the wrong type to access storage.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com


More information about the Gcc mailing list