From f29cb50ff7dcb0c3f559cabe9886ce0df6610f8d Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Thu, 30 Jun 2011 21:43:23 +1000 Subject: [PATCH] Avoid type punning by using an integer/float union --- float.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/float.cpp b/float.cpp index 4e0e529a..31669910 100644 --- a/float.cpp +++ b/float.cpp @@ -61,8 +61,15 @@ ieee_float::operator==(floating_t _floating) const { // representative native floating point type. But I'm sick of // C++'s template bullshit for tonight. check_hard (bits_type::has_floating); - - return m_bits == *(const uint_t*)&_floating; + + union { + floating_t _floating; + uint_t _uint; + } convertor; + + convertor._floating = _floating; + + return m_bits == convertor._uint; }