From 8df9f97cdaba7bd846c42321f9c2618c9e0ea12d Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Fri, 18 Nov 2016 09:49:31 -0800 Subject: Silence 'cast increases required alignment of target type' warnings These warnings are emitted on some GCC versions when targeting ARM; the alignment is guaranteed to be correct due to how page offsets are set up but the compiler doesn't know. --- src/pugixml.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pugixml.cpp b/src/pugixml.cpp index 72cab1f..cac51a5 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -424,7 +424,8 @@ PUGI__NS_BEGIN #define PUGI__GETPAGE_IMPL(header) (header).get_page() #else #define PUGI__GETHEADER_IMPL(object, page, flags) (((reinterpret_cast(object) - reinterpret_cast(page)) << 8) | (flags)) - #define PUGI__GETPAGE_IMPL(header) const_cast(reinterpret_cast(reinterpret_cast(&header) - (header >> 8))) + // this macro casts pointers through void* to avoid 'cast increases required alignment of target type' warnings + #define PUGI__GETPAGE_IMPL(header) static_cast(const_cast(static_cast(reinterpret_cast(&header) - (header >> 8)))) #endif #define PUGI__GETPAGE(n) PUGI__GETPAGE_IMPL((n)->header) -- cgit v1.2.3