From 37b54179d882fef38ca6735b53e322027414b62e Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 3 Apr 2019 16:59:53 +0200 Subject: [PATCH] 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 --- NEWS | 1 + src/net/IPv4Address.hxx | 2 +- src/net/IPv6Address.hxx | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 90eb2286e..388f8dd7b 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,5 @@ ver 0.21.8 (not yet released) +* fix build failure with GCC 9 ver 0.21.7 (2019/04/03) * input diff --git a/src/net/IPv4Address.hxx b/src/net/IPv4Address.hxx index 7a39ed016..3af0210c3 100644 --- a/src/net/IPv4Address.hxx +++ b/src/net/IPv4Address.hxx @@ -168,7 +168,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 e9531b3f7..eae9b60c1 100644 --- a/src/net/IPv6Address.hxx +++ b/src/net/IPv6Address.hxx @@ -135,7 +135,7 @@ public: } constexpr operator SocketAddress() const noexcept { - return SocketAddress((const struct sockaddr *)&address, + return SocketAddress((const struct sockaddr *)(const void *)&address, sizeof(address)); }