Question about -Wstrict-overflow=2
Andrew Haley
aph@redhat.com
Tue Mar 9 09:09:51 GMT 2021
On 3/8/21 9:05 PM, Martin Sebor via Gcc-help wrote:
> I think rewriting the test as an equality would be an improvement:
> argptr is incremented by 1 in each iteration so there's no way for
> the pointer to be greater than endbuf.
>
> if (argptr == endbuf)
> return false;
You can, but it arguably makes the code more fragile and less easy
to reason about. I'm not in favour of tying programs in knots in order
to appease warnings.
--
Andrew Haley (he/him)
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
https://keybase.io/andrewhaley
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671
More information about the Gcc-help
mailing list