Commit 82344f8
committed
Fix MinGW Error
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.1 parent f606f9a commit 82344f8
2 files changed
+4
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
64 | 65 | | |
65 | 66 | | |
66 | | - | |
| 67 | + | |
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
49 | | - | |
| 50 | + | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| |||
0 commit comments