https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111028
--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> --- Converting _node_offset from a pointer into an integer offset seems to fix the testcase: diff --git a/111028.C b/111028.C index ed4106e..ef2b1be 100644 --- a/111028.C +++ b/111028.C @@ -15,7 +15,7 @@ class list_t public: list_t() { _head.next = _head.prev = &_head; } bool is_empty() const { return _head.next == &_head; } - T* entry(list_node_t &node) const { return &node == &_head ? NULL : (T*)((char*)&node - (char*)_node_offset); } + T* entry(list_node_t &node) const { return &node == &_head ? NULL : (T*)((char*)&node - _node_offset); } void add(T &node) { @@ -37,11 +37,11 @@ class list_t } protected: - static list_node_t const * const _node_offset; + static size_t const _node_offset; list_node_t _head; }; template <typename T, list_node_t T::*inner_list_node> -list_node_t const * const list_t<T, inner_list_node>::_node_offset = &(((T *)0)->*inner_list_node); +size_t const list_t<T, inner_list_node>::_node_offset = size_t(&(((T *)0)->*inner_list_node)); template <typename T, list_node_t T::*inner_list_node> class safe_list_t: public list_t<T, inner_list_node>