commit 37b54179d882fef38ca6735b53e322027414b62e Author: Max Kellermann Date: Wed Apr 3 16:59:53 2019 +0200 net/IPv[46]Address: add cast to void* to fix GCC9 build failure Fixes: src/net/IPv4Address.hxx: In member function 'constexpr IPv4Address::operator SocketAddress() const': src/net/IPv4Address.hxx:171:24: error: a reinterpret_cast is not a constant expression 171 | return SocketAddress((const struct sockaddr *)&address, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/net/IPv6Address.hxx: In member function 'constexpr IPv6Address::operator SocketAddress() const': src/net/IPv6Address.hxx:138:24: error: a reinterpret_cast is not a constant expression 138 | return SocketAddress((const struct sockaddr *)&address, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Closes https://github.com/MusicPlayerDaemon/MPD/issues/522 diff --git a/src/net/IPv4Address.hxx b/src/net/IPv4Address.hxx index d8be8e5..c8fead1 100644 --- a/src/net/IPv4Address.hxx +++ b/src/net/IPv4Address.hxx @@ -163,7 +163,7 @@ public: } constexpr operator SocketAddress() const noexcept { - return SocketAddress((const struct sockaddr *)&address, + return SocketAddress((const struct sockaddr *)(const void *)&address, sizeof(address)); } diff --git a/src/net/IPv6Address.hxx b/src/net/IPv6Address.hxx index 6f21777..0439c0e 100644 --- a/src/net/IPv6Address.hxx +++ b/src/net/IPv6Address.hxx @@ -127,7 +127,7 @@ public: } constexpr operator SocketAddress() const noexcept { - return SocketAddress((const struct sockaddr *)&address, + return SocketAddress((const struct sockaddr *)(const void *)&address, sizeof(address)); }