Am 19.08.2019 um 22:35 schrieb Bruno Haible:
> Eli Zaretskii wrote:
>> One other issue is that GCC 8 flags many uses of strncat in
>> install-info.c as unsafe:
>>
>>      install-info.c: In function 'split_entry':
>>      install-info.c:1624:17: warning: 'strncat' specified bound 2 equals 
>> source length [-Wstringop-overflow=]
>>                       strncat (*description, "  ", 2);
>>                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
> 
> The warnings are clearly pointless, because the amount of memory
> allocated for *description is unknown to the compiler.

I disagree here.  There is indeed something fishy here, but the warning
is quite definitely not pointless.

*) The warning is explicitly about the _source_ buffere size, not that
of the destination, so whether or not GCC can know the size of
*description here is irrelevant.

*) The warning is not entirely unjustified, because the above code is,
at the least, somewhat misleading.  The actual number of characters this
will add to the output is not 2, as it appears to say right there in the
argument list, but 3 (because strncat insists on writing a closing '\0').

*) IMHO there must be something wrong with that GCC: the text of the
warning mismatches the indicated -W option.  This warning is
-Wstringop-truncation, not -Wstringop-overflow


Reply via email to