Floating Pt. Optimize on PA

Gavin Romig-Koch gavin@cygnus.com
Mon Dec 28 14:12:00 GMT 1998


Nicholas Sterling writes:
 > In the meantime, Jeffrey, please help me out here.  Is the spec saying
 > that this would be OK (because character types are explicitly allowed)
 > 
 >         double d = 1.0;
 >         char *p = (char *) &d;
 >         while ( p < (char *) (&d + 1) )
 >                 printf( "%x\n", *p++ );
 > 
 > but this (same thing, but int instead of char) would not?
 > 
 >         double d = 1.0;
 >         int *p = (int *) &d;
 >         while ( p < (int *) (&d + 1) )
 >                 printf( "%x\n", *p++ );
 > 
 > Then what *is* the correct way to access the two words that comprise a
 > doubleword object?

memcpy it to an array of ints, and manipulate it, memcpy it back if
you want to change the double; use memmove instead if the array of
ints and the double could overlap.

                                            -gavin...







More information about the Gcc-bugs mailing list