[Numpy-discussion] strict aliasing?
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
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
More information about the Numpy-discussion