[Vm-dev] getting rid of pointer aliasing

Eliot Miranda eliot.miranda at gmail.com
Sat Mar 5 00:26:15 UTC 2016

Hi Nicolas,

On Fri, Mar 4, 2016 at 1:46 PM, Nicolas Cellier <
nicolas.cellier.aka.nice at gmail.com> wrote:

> Hi,
> pointer aliasing is evil/dangerous on modern C Compiler.
> Though it's kind of easy to remove most of them.
> For example:
>     self cCode:'((long *)addr)[0] = ((long *)(&floatValue))[0]'.
> can easily become:
>     self cCode: [self mem: addr cp: (self addressOf: floatValue) y: (self
> sizeof: floatValue)].
> Modern compiler will generate very efficient code for that.
> Would you like me to proceed?

Yes, but please use this form where possible:

    self mem: addr cp: (self addressOf: floatValue) y: (self sizeof:

The cCode: approach is not a;ways needed.  VMClass and SpurMemoryManager
provide implementations of some of the C library that actually work in

> Nicolas

best, Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20160304/c708c960/attachment.htm

More information about the Vm-dev mailing list