[Numpy-discussion] strict aliasing?

Charles R Harris charlesr.harris at gmail.com
Mon May 5 02:52:57 EDT 2008


On Sun, May 4, 2008 at 11:16 PM, David Cournapeau <
david at ar.media.kyoto-u.ac.jp> wrote:

> Charles R Harris wrote:
>
> >
> > As far as I can tell, strict aliasing assumes that pointers are only
> > cast between types of the same length.
>
> Strictly speaking, strict aliasing just says that locations pointed by
> pointers do not alias. If you use two pointers of different types,
> that's one case where the compiler will always assume they do not alias.


Interesting article. I note that it is OK to alias pointers to the signed
and unsigned versions of integer types, which is where I must have picked up
my notions about length. I don't recall seeing any major bit of software
that didn't use the -fno-strict-aliasing flag, as casting pointers around is
one of the things C is(was) all about. So I was a bit surprised that Mike
was recommending not doing so, although making the choice on a file by file
basis might be useful for the optimizer. But the assumption of pointers and
aliasing is so built into the whole C outlook that I wouldn't be surprised
if any large program developed obscure bugs when compiled with the
strict-aliasing flag.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20080505/eb5a4316/attachment.html>


More information about the NumPy-Discussion mailing list