>gcc does this (assumes that two variables of different types can not
>refer to the same object) not to blindly follow the standard, but
>because it permits a number of optimizations which are not otherwise
>permitted.
Yes, we know; no need to be condescending. And there's a good case
that that *is* blindly following the standard, at least by certain
local lights. The issue isn't a strict legalese reading of the
standard; its an issue of a culture of (pre-C99) C coding in embedded,
or machine-dependent environments like OS kernels.
>These optimizations are off by default, but are turned on by default
>at -O2 and greater. You can turn them off using -fno-strict-aliasing.
I that's the root of the problem: having -fstrict-aliasing on by
default for -O2. IT seems pretty ill-considered to me, in that this
*is* a language change (vis-a-vis previous versions of gcc). I'd have
argued to leave it off, unless explicitly compiling with -ansi.
(Personally I think its a very nice fit for -ansi -pedantic, tho'
thats not what those flags have historically meant for gcc).