From febc20fef1490a4ca9f7b0264a32b271760e370e Mon Sep 17 00:00:00 2001 From: Diego Lopez Recas Date: Thu, 16 Sep 2021 17:25:04 +0100 Subject: Fix undefined reinterpret_cast in BFloat16.hpp This fixes gcc builds with version 8 or above. Signed-off-by: Diego Lopez Recas Change-Id: I4b886854f4f3391f766e95c3478d3a5f9661507a --- src/armnnUtils/BFloat16.hpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/armnnUtils/BFloat16.hpp b/src/armnnUtils/BFloat16.hpp index 52344db810..a293cd488c 100644 --- a/src/armnnUtils/BFloat16.hpp +++ b/src/armnnUtils/BFloat16.hpp @@ -7,6 +7,7 @@ #include #include +#include #include namespace armnn @@ -85,8 +86,10 @@ public: float ToFloat32() const { const uint32_t u32 = static_cast(m_Value << 16u); - const float* f32 = reinterpret_cast(&u32); - return *f32; + float f32; + static_assert(sizeof u32 == sizeof f32, ""); + std::memcpy(&f32, &u32, sizeof u32); + return f32; } uint16_t Val() const -- cgit v1.2.1