From 4da8dd90f29a849bcba19463598ce8215a8915eb Mon Sep 17 00:00:00 2001 From: g0dil <g0dil@wiback.org> Date: Tue, 25 Nov 2008 13:05:15 +0000 Subject: [PATCH] Socket/Protocols: Really fix 64bit alignment issue --- Socket/Protocols/BSDSocketAddress.hh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Socket/Protocols/BSDSocketAddress.hh b/Socket/Protocols/BSDSocketAddress.hh index 9fbc5f01a..ec3edfdf0 100644 --- a/Socket/Protocols/BSDSocketAddress.hh +++ b/Socket/Protocols/BSDSocketAddress.hh @@ -114,10 +114,15 @@ namespace senf { void socklen(socklen_t len); private: - + + // The following incantation is needed to fix the alignment of the sockaddr data members + // which will be added by the derived classes later: The alignment must be forced + // to coincide with the struct sockaddr_storage alignment (which must have the largest + // alignment of all sockaddr types). union { socklen_t len_; - boost::type_with_alignment<boost::alignment_of<struct sockaddr_storage>::value> _; + boost::type_with_alignment<boost::alignment_of<struct sockaddr_storage>::value> a_; + char _b[boost::alignment_of<struct sockaddr_storage>::value]; }; }; -- GitLab