On Sat, 2009-05-02 14:44:02 +0200, Michal Trojnara wrote:
Miloslav Trmac wrote:
The attached patch changes the code not to access a part of a char[...] array using an int *, which is undefined in ISO C.
Casting pointers is undefined? On some architectures it could make sense due to data alignment issues, but I really didn't know that. Where did you find it?
I suppose Miloslav didn't want to say 'undefined', but 'leads to undefined behavior'.
In fact, accessing objects at addresses not suitable aligned leads to strange effects on some machines (e.g. ARM9 or C165), but this fact is not even mentioned in IEC9899:1999 (a.k.a. C99).
Even worse C99 _defines_ void* to "have the same representation and alignment requirements as a pointer to a character type", which is not suitable the vast majority of the objects one could have pointers for. A nightmare for static code checkers ...
Ludolf