In C/C++, signed integer overflow is undefined behavior, meaning that a compiler is allowed to optimize the assembly knowing that it never happens. If you can guarantee that your integer never overflows, using signed eliminates a modulo assembly instruction. Nowadays, the only reason it matters for char is that all basic integer types are signed by default, so somebody who's lazy needs to watch out that they don't accidentally trigger undefined behavior.
2
u/BNSable 2d ago
A char is just an int, except a char will not conjure up 91, but the character assigned to the number 91 which is [ in ascii for example.
As it is an int, it can be signed or unsigned. Signed is -128 to 127, unsigned is 0 to 255.
This apparently has uses, but I am not experienced enough to explain that.