mirror of
https://github.com/eledio-devices/thirdparty-ArduinoJson.git
synced 2025-11-02 08:48:27 +01:00
Fixed strict-aliasing warning in FloatTraits.hpp
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include <stddef.h> // for size_t
|
||||
#include <stdint.h>
|
||||
#include "../Configuration.hpp"
|
||||
#include "../Polyfills/alias_cast.hpp"
|
||||
#include "../Polyfills/math.hpp"
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
@@ -98,8 +99,7 @@ struct FloatTraits<T, 8 /*64bits*/> {
|
||||
// we use this function to workaround platforms with single precision literals
|
||||
// (for example, when -fsingle-precision-constant is passed to GCC)
|
||||
static T forge(uint32_t msb, uint32_t lsb) {
|
||||
uint64_t bits = (uint64_t(msb) << 32) | lsb;
|
||||
return *reinterpret_cast<T*>(&bits);
|
||||
return alias_cast<T>((uint64_t(msb) << 32) | lsb);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -146,7 +146,7 @@ struct FloatTraits<T, 4 /*32bits*/> {
|
||||
}
|
||||
|
||||
static T forge(uint32_t bits) {
|
||||
return *reinterpret_cast<T*>(&bits);
|
||||
return alias_cast<T>(bits);
|
||||
}
|
||||
|
||||
static T nan() {
|
||||
|
Reference in New Issue
Block a user