Date: Thu, 16 Apr 2026 10:05:13 +0000
On Thursday, April 16th, 2026 at 6:51 AM, Steve Weinrich via Std-Proposals <std-proposals_at_[hidden]> wrote:
> I find it very interesting that folk think the argument should be signed. I have found that a very large percentage of ints should really be unsigned as negative values are not permitted in normal usage.
> As an example, I have used, and seen, this an uncountable number of times:
>
> T array[10];
>
> for (int i = 0; i < 10; ++i) { stuff }
>
> I have been embracing unsigned ints more and more in an effort to make it clear that negative values are not permitted.
There's some sense in using signed int for induction variables, because
overflow being UB gives the compiler more room to optimize. With an
unsigned int, the compiler must consider the case where the value wraps
around (not in this specific example, but in general), which means you
have to be more careful about the specific types.
https://godbolt.org/z/Kv1afGjaf
> I find it very interesting that folk think the argument should be signed. I have found that a very large percentage of ints should really be unsigned as negative values are not permitted in normal usage.
> As an example, I have used, and seen, this an uncountable number of times:
>
> T array[10];
>
> for (int i = 0; i < 10; ++i) { stuff }
>
> I have been embracing unsigned ints more and more in an effort to make it clear that negative values are not permitted.
There's some sense in using signed int for induction variables, because
overflow being UB gives the compiler more room to optimize. With an
unsigned int, the compiler must consider the case where the value wraps
around (not in this specific example, but in general), which means you
have to be more careful about the specific types.
https://godbolt.org/z/Kv1afGjaf
Received on 2026-04-16 10:05:20
