From ea1ac1cca3f044133c2968e163761f477342bd9c Mon Sep 17 00:00:00 2001 From: rexy712 Date: Sat, 2 May 2020 22:30:21 -0700 Subject: [PATCH] Fix false flag strict alias warnings --- include/rexy/binary.hpp | 2 ++ include/rexy/string_base.tpp | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/rexy/binary.hpp b/include/rexy/binary.hpp index df6a276..8b9e406 100644 --- a/include/rexy/binary.hpp +++ b/include/rexy/binary.hpp @@ -173,6 +173,8 @@ namespace rexy{ } } //namespace rexy +#undef STOP_STRICT_ALIAS_WARNING + #ifdef REXY_STRING_BASE_HPP #include "detail/binary_string_conv.hpp" #endif diff --git a/include/rexy/string_base.tpp b/include/rexy/string_base.tpp index 48ab29b..fdb32bc 100644 --- a/include/rexy/string_base.tpp +++ b/include/rexy/string_base.tpp @@ -25,6 +25,8 @@ #include "cx/utility.hpp" //max +#define STOP_STRICT_ALIAS_WARNING(x) (x) + namespace rexy{ template @@ -158,9 +160,9 @@ namespace rexy{ }else{ string_intermediary tmp(cx::max(m_length + len, m_cap*2)); if(m_data) - memcpy(tmp.m_data, m_data, m_length); - memcpy(tmp.m_data+m_length, data, len); - tmp.m_length = len+m_length; + memcpy(STOP_STRING_ALIASING_WARNING(tmp).m_data, m_data, m_length); + memcpy(STOP_STRING_ALIASING_WARNING(tmp).m_data+m_length, data, len); + STOP_STRING_ALIASING_WARNING(tmp).m_length = len+m_length; tmp[m_length+len] = 0; *this = std::move(tmp); } @@ -275,4 +277,6 @@ namespace rexy{ } //namespace rexy +#undef STOP_STRICT_ALIAS_WARNING + #endif