Strict aliasing in D
monarch_dodra
monarchdodra at gmail.com
Sat Jul 27 01:08:00 PDT 2013
On Saturday, 27 July 2013 at 06:58:04 UTC, Walter Bright wrote:
> On 7/26/2013 12:45 PM, monarch_dodra wrote:
>> On Sunday, 29 January 2012 at 16:25:33 UTC, Peter Alexander
>> wrote:
>>> As for D, I can't see anything in the standard that prevents
>>> two pointers of
>>> different types from pointing to the same location, but I
>>> suspect it is an
>>> assumption that is being made.
>>
>> Resurrecting this old thread, maybe we'll get a better answer
>> this time. I too
>> am interested in knowing how D deals with pointer aliasing.
>>
>> I'd like a bit more of an "official" or "factual" answer.
>
> 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
Thank you for the answer. I expected D to do strict aliasing for
the reasons you mentioned. This does come up with two follow up
question though:
1. Does strict aliasing apply to slices?
2. C++ uses 'char' as a 'neutral' type that can alias to
anything. What about D? Does char fill that role? Does ubyte?
More information about the Digitalmars-d
mailing list