get a struct member pointer

grauzone none at example.net
Mon Feb 16 05:20:36 PST 2009


bearophile wrote:
> Daniel Keep:
>> void lookup(T)(T[] s, size_t offset)
>> {
>>   char[] text = *cast(char[]*)(cast(void*)(&s[0]) + offset);
>> }
> 
> I am learning still this topic, but can't this create an aliasing problem, as in C?
> http://www.cellperformance.com/mike_acton/2006/06/understanding_strict_aliasing.html

My theory is, that Walter's code generator is too primitive to care 
about aliasing. But I guess it's possible, that aliasing rules will be 
added later to the language, when LDC (hopefully) gets big?

By the way, wtf is Daniel's code doing at all?

> Bye,
> bearophile


More information about the Digitalmars-d-learn mailing list