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

Reply via email to