diff --git a/view.hpp b/view.hpp index 8d9d785b..542b87e5 100644 --- a/view.hpp +++ b/view.hpp @@ -22,6 +22,7 @@ #include "cast.hpp" #include "types/traits.hpp" #include "maths.hpp" +#include "platform.hpp" #include #include @@ -653,6 +654,14 @@ namespace util { ValueT read (util::view &buffer) { + // we disable the class-memaccess warning so that we can memcpy into + // types that we know are safe but the compiler will complain about. + // this occurs commonly with oddly packed structures, eg anything + // that uses gnu::packed +#if defined(COMPILER_GCC) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wclass-memaccess" +#endif if (unlikely (sizeof (ValueT) > buffer.size ())) throw std::runtime_error ("insufficient data for extraction"); @@ -660,6 +669,9 @@ namespace util { memcpy (&res, buffer.data (), sizeof (ValueT)); buffer = buffer.consume (sizeof (ValueT)); return res; +#if defined(COMPILER_GCC) +#pragma GCC diagnostic pop +#endif }