Strict aliasing in D

Walter Bright newshound2 at digitalmars.com
Fri Jul 26 23:58:04 PDT 2013


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


More information about the Digitalmars-d mailing list