Skip to content

Conversation

@HRex39
Copy link
Contributor

@HRex39 HRex39 commented Mar 20, 2025

const auto& addr = this->At(n);
auto tmp_addr = addr;

the line auto tmp_addr = addr; creates a copy of the object referred to by addr. This copy, tmp_addr, is not marked as const even though addr is a constant reference. As a result, the address of tmp_addr (i.e., &tmp_addr) is of a non-const pointer type, which is acceptable for the inet_ntop function.

Passing &tmp_addr to inet_ntop solves the issue of an invalid conversion from const void* to void*, because &tmp_addr is now of the type void* (or can be implicitly converted to it), bypassing the compiler error that would occur if you tried to pass directly &addr.

This approach is valid provided that this->At(n) returns the data in a way that allows creating a copy with auto tmp_addr without any unintended side effects.

const auto& addr = this->At(n);
auto tmp_addr = addr;

the line auto tmp_addr = addr; creates a copy of the object referred to by addr. This copy, tmp_addr, is not marked as const even though addr is a constant reference. As a result, the address of tmp_addr (i.e., &tmp_addr) is of a non-const pointer type, which is acceptable for the inet_ntop function.

Passing &tmp_addr to inet_ntop solves the issue of an invalid conversion from const void* to void*, because &tmp_addr is now of the type void* (or can be implicitly converted to it), bypassing the compiler error that would occur if you tried to pass directly &addr.

This approach is valid provided that this->At(n) returns the data in a way that allows creating a copy with auto tmp_addr without any unintended side effects.
@CLAassistant
Copy link

CLAassistant commented Mar 20, 2025

CLA assistant check
All committers have signed the CLA.

@Enmk Enmk merged commit fbd7945 into ClickHouse:master Apr 1, 2025
16 checks passed
@HRex39 HRex39 deleted the Fix-MinGW-Error branch August 1, 2025 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants