Strict aliasing in D
bearophile
bearophileHUGS at lycos.com
Sat Jul 27 06:28:38 PDT 2013
Walter Bright:
> Although it isn't in the spec, D should be "strict aliasing".
> This is because:
>
> 1. it enables better code generation
>
> 2. there are ways, such as unions, to get the other aliasing
> that doesn't break strict aliasing
Is it good to add to Phobos a small template (named like
"PointerCast" or something similar) that uses a union internally
to perform pointer type conversions?
Is then the compiler going to warn the programmer when the
pointer type aliasing rule is violated? I mean when the D code
uses cast() between different pointer types (beside constness).
An alternative design is to even deprecate (and later turn those
into errors, where the error message suggests to use PointerCast).
Bye,
bearophile
More information about the Digitalmars-d
mailing list