[Numpy-discussion] strict aliasing?
David Cournapeau
david@ar.media.kyoto-u.ac...
Mon May 5 00:16:24 CDT 2008
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.
And this breaks heavily I think in numpy, where a lot of casting is
done, since internally a data buffer is a char*.
Converting from char* to any other type pointer often breaks the strict
aliasing rule:
http://www.cellperformance.com/mike_acton/2006/06/understanding_strict_aliasing.html#cast_to_char_pointer
Using numscons with numpy trunk:
CFLAGS="-fstrict-aliasing -Wstrict-aliasing" python setupscons.py scons
certainly generate tons of warnings, and -Wstrict-aliasing does only
catch the most common ones. It is pretty safe to say it is not safe at
all :)
cheers,
David
More information about the Numpy-discussion
mailing list