Hi Patrice,

Patrice Dumas <[email protected]> writes:

> I realized that there was a bug because I had set SEARCH_BINDING start
> and end offsets to size_t, which lead s.start becoming the max size_t
> value (and to a segfault), I had not seen it while reviewing the code
> for such possibilities.
>
> Keeping long could hide some bugs of offsets becoming negative, but also
> be more robust in face of those bugs if it does not matter much that the
> offsets become negative.
>
> Any advice?

I can't speak to this specific case. But just a warning that if your
goal is to enable -Wsign-compare you will run into issues with Gnulib
spamming the build output.

It is easier for unsigned integer overflow to go unnoticed since it is
well-defined behavior in C. Signed integer overflow will trigger
-fsanitize=undefined.

That is the main advantage in my opinion, but you can find more
reasoning in Gnulib's idx.h [1]. Probably some more discussion you can
dig up on bug-gnulib too.

Collin

[1] https://git.savannah.gnu.org/cgit/gnulib.git/tree/lib/idx.h

Reply via email to