------- Comment #2 from rosenfeld at grumpf dot hope-2000 dot org  2007-06-19 
10:52 -------
Subject: Re:  wrong instruction order generated

On Tue, Jun 19, 2007 at 07:56:01AM -0000, pinskia at gcc dot gnu dot org wrote:
> ------- Comment #1 from pinskia at gcc dot gnu dot org  2007-06-19 07:56 
> -------
> ((Cyg_libm_ieee_double_shape_type *)&x)->part is ovbiously an aliasing
> violation.

I doubt that. As you can see in the source file, x is a double and
Cyg_libm_ieee_double_shape_type is a union containing a double. 

To quote the standard,
 7 An object shall have its stored value accessed only by an lvalue
   expression that has one of the following types:
    a type compatible with the effective type of the object,
        [...]
    an aggregate or union type that includes one of the aforementioned
     types among its members (including, recursively, a member of a
     subaggregate or contained union) [...]

So as far as I understand this should be perfectly legal by the ISO C
standard.

Maybe I'm missing somthing here, I read everywhere that using a union
for this kind of thing is a gcc extension. I wonder, if there is no
standard way to manipulate doubles by treating them as ints or bitfields
or something like that, how is one supposed to write a floating point
emulator in ISO C?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32397

Reply via email to