Skip to content

Commit

Permalink
Merge pull request #6 from EOSIO/cleanup_type_punning
Browse files Browse the repository at this point in the history
clean up strict-aliasing rules warnings
  • Loading branch information
spoonincode authored May 13, 2019
2 parents 203b6df + 77c42dd commit 94dac6e
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions source/include/softfloat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,22 @@ inline float128_t f128_positive_infinity() {
}

inline float32_t to_softfloat32( float f ) {
return *reinterpret_cast<float32_t*>(&f);
float32_t x;
memcpy(&x, &f, sizeof(f));
return x;
}
inline float64_t to_softfloat64( double d ) {
return *reinterpret_cast<float64_t*>(&d);
float64_t x;
memcpy(&x, &d, sizeof(d));
return x;
}
inline float from_softfloat32( float32_t f ) {
return *reinterpret_cast<float*>(&f);
float x;
memcpy(&x, &f, sizeof(f));
return x;
}
inline double from_softfloat64( float64_t d ) {
return *reinterpret_cast<double*>(&d);
double x;
memcpy(&x, &d, sizeof(d));
return x;
}

0 comments on commit 94dac6e

Please sign in to comment.