diff --git a/src/pugixml.cpp b/src/pugixml.cpp index 586d53c..dad8711 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -758,10 +758,11 @@ PUGI__NS_BEGIN xml_memory_page* get_page() const { + // round-trip through void* to silence 'cast increases required alignment of target type' warnings const char* page_marker = reinterpret_cast(this) - (_page << compact_alignment_log2); - const char* page = page_marker - *reinterpret_cast(page_marker); + const char* page = page_marker - *reinterpret_cast(static_cast(page_marker)); - return const_cast(reinterpret_cast(page)); + return const_cast(reinterpret_cast(static_cast(page))); } private: @@ -953,7 +954,8 @@ PUGI__NS_BEGIN if (static_cast(offset) < (65535 << 7)) { - uint16_t* base = reinterpret_cast(reinterpret_cast(this) - base_offset); + // round-trip through void* to silence 'cast increases required alignment of target type' warnings + uint16_t* base = reinterpret_cast(static_cast(reinterpret_cast(this) - base_offset)); if (*base == 0) { @@ -997,7 +999,8 @@ PUGI__NS_BEGIN { xml_memory_page* page = compact_get_page(this, header_offset); - const uint16_t* base = reinterpret_cast(reinterpret_cast(this) - base_offset); + // round-trip through void* to silence 'cast increases required alignment of target type' warnings + const uint16_t* base = reinterpret_cast(static_cast(reinterpret_cast(this) - base_offset)); assert(*base); ptrdiff_t offset = ((*base - 1) << 7) + (_data - 1); @@ -6694,7 +6697,8 @@ namespace pugi // setup first page marker #ifdef PUGIXML_COMPACT - page->compact_page_marker = reinterpret_cast(reinterpret_cast(page) + sizeof(impl::xml_memory_page)); + // round-trip through void* to avoid 'cast increases required alignment of target type' warning + page->compact_page_marker = reinterpret_cast(static_cast(reinterpret_cast(page) + sizeof(impl::xml_memory_page))); *page->compact_page_marker = sizeof(impl::xml_memory_page); #endif