On Tue, 2007-11-06 at 07:58 -0800, Ian Lance Taylor wrote: > Joe Buck <[EMAIL PROTECTED]> writes:
> In particular people really do write code like > int addr = 0x12345678; > char* p = (char*)&addr; > *p = 1; > and > int f[2] = { 0x80000000, 0 }; > double d = *(double*)f; > This is not valid C/C++ code. What you mean is that it is not strictly conforming C code. [You cannot say that for C++, there is no notion of strictly conforming C++ code] > But since there is quite a lot of it > out there, the -fno-strict-aliasing rule makes it work correctly. Yes. This is overkill for me: making that work would disable too many optimisations for my taste. BTW: gcc handles these rules very cleverly indeed. I have played with some code and things like union-ing an unsigned char array correctly defeat the optimisations. I'm quite surprised, this is very hard to get right. -- John Skaller <skaller at users dot sf dot net> Felix, successor to C++: http://felix.sf.net