5 ms·
-Wsign-compare is a typical example of warning that implies a serious error unless you prove it couldn't happen; spending, typically, more effort than would be
by HelloNurse 5y ago
-Wsign-compare is a typical example of warning that implies a serious error unless you prove it couldn't happen; spending, typically, more effort than would be needed to actually fix the warning.
- flohofwoe 5y agoWell yeah, but then there's stupid design warts like size_t being unsigned, and it's much too late to fix this now.
- microtherion 5y agoHow many objects of negative size are you typically dealing with?
- flohofwoe 5y agoThis isn't the problem, but that it almost always makes sense to use signed math for computations (including computations that involve sizes). And mixed-sign-math in a language that doesn't have robust over/underflow detection but implicit conversion between signed and unsigned is usually a very bad idea. The only advantage that an unsigned size_t gives is one bit more range (but these days this is irrelevant - 63 bits ought to be enough for anyone). But this topic really has been discussed to death in the last decade or so :)