mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-15 12:23:15 +00:00
AK+DHCPClient: Fix false positive gcc 12 warnings
The compiler would complain about `__builtin_memcpy` in ByteBuffer::copy writing out of bounds, as it isn't able to deduce the invariant that the inline buffer is only used when the requested size is smaller than the inline capacity. The other change is more bizarre. If the destructor's declaration exists, gcc complains about a `delete` operation causing an out-of-bounds array access. error: array subscript 'DHCPv4Client::__as_base [0]' is partly outside array bounds of 'unsigned char [8]' [-Werror=array-bounds] 14 | ~DHCPv4Client() = default; | ^ This looks like a compiler bug, and I'll report it if I find a suitable reduced reproducer.
This commit is contained in:
parent
f40b6fbd07
commit
014b9fd709
|
@ -80,6 +80,8 @@ public:
|
|||
[[nodiscard]] static ErrorOr<ByteBuffer> copy(void const* data, size_t size)
|
||||
{
|
||||
auto buffer = TRY(create_uninitialized(size));
|
||||
if (buffer.m_inline && size > inline_capacity)
|
||||
__builtin_unreachable();
|
||||
if (size != 0)
|
||||
__builtin_memcpy(buffer.data(), data, size);
|
||||
return { move(buffer) };
|
||||
|
|
|
@ -40,8 +40,6 @@ class DHCPv4Client final : public Core::Object {
|
|||
C_OBJECT(DHCPv4Client)
|
||||
|
||||
public:
|
||||
virtual ~DHCPv4Client() override = default;
|
||||
|
||||
void dhcp_discover(InterfaceDescriptor const& ifname);
|
||||
void dhcp_request(DHCPv4Transaction& transaction, DHCPv4Packet const& packet);
|
||||
|
||||
|
|
Loading…
Reference in a new issue