The Cocoa code has this in TBinaryProtocol:
- (void) writeDouble: (double) value
{
// spit out IEEE 754 bits - FIXME - will this get us in trouble on
// PowerPC?
[self writeI64: *((int64_t *) &value)];
}
this should be changed to
- (void) writeDouble: (double) value
{
// spit out IEEE 754 bits - FIXME - will this get us in trouble on
// PowerPC?
union {
int64_t i64;
double d;
} u;
u.d = value;
[self writeI64: u.i64];
}
since the current code violates C strict aliasing rules -- it works but it's
undefined behavior.
C.f. <http://labs.qt.nokia.com/2011/06/10/type-punning-and-strict-aliasing/>
Daniel