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

_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to