On Tue, Oct 08, 2024 at 05:05:59PM +0100, Gavin Smith wrote: > On Tue, Oct 08, 2024 at 01:46:56AM +0200, Patrice Dumas wrote: > > Hello, > > > > In the info reader, as part of an effort to avoid comparison of signed > > and unsigned integers, and also to have a clearer code, I am considering > > setting SEARCH_BINDING start and end offsets to size_t instead of long. > > Indeed, this should be a bug if they are negative (although there were > > places in the code where they could become negative temporarily, before > > being reset to 0 right after, which I modified). > > As Eli said, unsigned types in C can be dangerous. I have spent hours > in the past on several occasions trying to debug programs that misused > unsigned types, including the info reader. Having suffered this, I > object to this changing on the basis of so-called clarity or correctness.
Ok. > Simply blindly changing long to size_t throughout a program is unlikely > to be correct. Ok. I was doing it carefully, but still... I will change the strategy to rather use signed everywhere to avoid comparison issues, rather than unsigned an signed. What about using the idx_t type as a replacement for size_t when a positive only index or length is expected? I like that idea, to combine code clarity, and using (size_t size/2) signed integers? -- Pat
