Michal Jaegermann wrote: > On Wed, Apr 18, 2001 at 06:18:13PM -0400, Uncle George wrote: > > Its not my code segment, and from my experience a union might be better. > > although from this discourse not safe either. > > > > the code as stated should: > > 1) take address of x > > 2) make into int ptr > > 3) add 1 to ptr ( value of 4 bec its an int ptr ) > > 4) fetch integer from the address as calculated. > > Well, yes, you translated the code from C to English. But the > question really was what you expect that it will happen after these > operations and what kind of a _meaning_ you ascribe to that. What happens after is also irrelevant, as there is no point on continuing with the routine if steps 1-4 of the equation dont happen. i ascribe no particular meaning to either I0, or I1. Just need to realize that the results are different between optimizations. > > > > It should not matter if at x there is 8 bytes of a double, as that > > distinction is superflous to the equation. > > But if you think that some consistent results should come from this > program then you assume that such "pointer puns" have a well defined > semantics. I do not recall that they ever had. > I hope that pointer arith is well defined. and should yield the same results with -O0 -O1 -O2 and so on. > > > anyway the segment was taken from a floor() function (akin to glibc: > > ./sysdeps/ieee754/dbl-64/s_floor.c). > > This may even work for some particular platform and some particular > compiler, so it may be ok in internals of libraries, but it does > not mean that it can be copied elsewhere. > yup, ergo the majic statement to disassemble the double to 2 ints is a macro. But again, irrelevant to talk about the various other architectures. I have only posted a CPP'd snippet of the problem code to demonstrate the erroneous results, as per gnu c bug reporting info. Whats a pointer pun? /gat