platform-testers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [platform-testers] texinfo-6.6.90 pretest


From: Eli Zaretskii
Subject: Re: [platform-testers] texinfo-6.6.90 pretest
Date: Tue, 20 Aug 2019 05:40:14 +0300

> From: Hans-Bernhard Bröker <address@hidden>
> Date: Tue, 20 Aug 2019 02:29:23 +0200
> Cc: address@hidden
> 
> *) 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').

There's nothing wrong with this code: the documentation of strncat
explicitly says that it will add a null terminator in addition to the
N characters copied.  This isn't memcpy.

> *) 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

I suggest to read about these warnings.  Then you will understand why
GCC wines about the source length: that's exactly what it wants to
prevent, this pattern of use where the length argument is taken from
the source instead of from the destination.

The problem is that to satisfy GCC, the code needs to keep track of
the amount of space left in the destination.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]