"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Ed Maste <emaste@freebsd.org>
Subject:
Re: use size_t for loop indices to avoid signedness comparison warnings
To:
stsp@stsp.name
Cc:
gameoftrees@openbsd.org
Date:
Thu, 26 Nov 2020 09:28:08 -0500

Download raw body.

Thread
On Thu, 26 Nov 2020 at 07:55, Stefan Sperling <stsp@stsp.name> wrote:
>
> On Wed, Nov 25, 2020 at 10:55:49PM -0500, Ed Maste wrote:
> > Found while attempting to build got as part of the FreeBSD base
> > system, which enabled additional warnings.
>
> Thank you! I have committed your patch.
>
> Which compiler flags are you using on FreeBSD?

Off hand I'm not entirely sure - I saw the warnings when I tried
adding got as a submodule to my wip-FreeBSD tree and building using
FreeBSD's share/mk/ files. I tried incrementally increasing the
top-level WARNS settings and saw these at some point. I'll try it
again and grab (from the build log) the exact flags that were applied.

> I have tried to reproduce the warnings you saw.
>
> If I add -Wsign-compare I get additional warnings such as this one
> on OpenBSD 6.8 with clang 10.0.1. Did you not see those or did you
> limit your patch to cases involving size_t?

I think that this patch was looking only at loop indexes; WARNS = 6
produced many warnings, and I wanted to reason about groups of them.
All of these cases were loops with a comparison against nitems().