[PATCH] [gdb/build] Use const_cast in fd_copy

Tom de Vries tdevries@suse.de
Mon Jan 6 09:05:44 GMT 2025


On 1/4/25 14:38, Eli Zaretskii wrote:
>> From: Tom de Vries <tdevries@suse.de>
>> Date: Sat,  4 Jan 2025 11:54:15 +0100
>>
>> Recent commit 6ab5d62ebc5 ("[gdb] Fix compilation error in event-top.c") did:
>> ...
>>   fd_copy (fd_set *dst, const fd_set *src, int n)
>>   {
>>     FD_ZERO (dst);
>>     for (int i = 0; i < n; ++i)
>> -    if (FD_ISSET (i, src))
>> +    if (FD_ISSET (i, (fd_set *)src))
>> ...
>> but according to [1] only const_cast may be used to cast away constness.
>>
>> Fix this by using const_cast.
>>
>> Tested by rebuilding on x86_64-linux.
> 
> Works for me, thanks.
> 

Hi Eli,

thanks for trying this out.

> Please also cherry-pick the fix to gdb-16-branch.

I've pushed this to master and gdb-16-branch.

Thanks,
- Tom


More information about the Gdb-patches mailing list