THRIFT-1992: Fix TCompactProtocol compiler warnings
Client: cpp
Patch: Konrad Grochowski
diff --git a/lib/cpp/src/thrift/protocol/TCompactProtocol.tcc b/lib/cpp/src/thrift/protocol/TCompactProtocol.tcc
index 79f1b6b..1d93cba 100644
--- a/lib/cpp/src/thrift/protocol/TCompactProtocol.tcc
+++ b/lib/cpp/src/thrift/protocol/TCompactProtocol.tcc
@@ -641,12 +641,13 @@
BOOST_STATIC_ASSERT(sizeof(double) == sizeof(uint64_t));
BOOST_STATIC_ASSERT(std::numeric_limits<double>::is_iec559);
- uint64_t bits;
- uint8_t b[8];
- trans_->readAll(b, 8);
- bits = *(uint64_t*)b;
- bits = letohll(bits);
- dub = bitwise_cast<double>(bits);
+ union {
+ uint64_t bits;
+ uint8_t b[8];
+ } u;
+ trans_->readAll(u.b, 8);
+ u.bits = letohll(u.bits);
+ dub = bitwise_cast<double>(u.bits);
return 8;
}