From e37ead5e9bfbe56ba4eeede592b90c032408ebb8 Mon Sep 17 00:00:00 2001 From: rexy712 Date: Sat, 4 Apr 2020 22:23:50 -0700 Subject: [PATCH] Ignore gcc's inaccurate strict aliasing warnings --- rexy/include/binary.hpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/rexy/include/binary.hpp b/rexy/include/binary.hpp index f68c251..e4fad7b 100644 --- a/rexy/include/binary.hpp +++ b/rexy/include/binary.hpp @@ -27,6 +27,8 @@ #include //max #include +#define STOP_STRICT_ALIAS_WARNING(x) (x) + namespace rexy{ class binary_base @@ -91,7 +93,7 @@ namespace rexy{ Allocator::free(m_data); } binary_data& operator=(const binary_data& b){ - binary_data tmp(b); + binary_data tmp(b); return (*this = std::move(tmp)); } binary_data& operator=(binary_data&& b){ @@ -114,12 +116,12 @@ namespace rexy{ bool resize(size_t newsize){ if(newsize < m_cap) return false; - binary_data tmp(newsize); + binary_data tmp(newsize); if(!tmp) return false; - memcpy(tmp.m_data, m_data, m_size); - std::swap(m_data, tmp.m_data); - m_cap = tmp.m_cap; + memcpy(STOP_STRICT_ALIAS_WARNING(tmp).m_data, m_data, m_size); + std::swap(m_data, STOP_STRICT_ALIAS_WARNING(tmp).m_data); + m_cap = STOP_STRICT_ALIAS_WARING(tmp).m_cap; return true; } void append(const char* data, size_t len){