3 ms·
> guarantee (u)int8_t == unsigned char You mean CHAR_BIT==8 as mandated by POSIX?
by nwellnhof 8y ago
> guarantee (u)int8_t == unsigned char
You mean CHAR_BIT==8 as mandated by POSIX?
- beefhash 8y agoIf uint8_t exists, then I believe the following ought to be true: 1. CHAR_BITS == 8, and 2. the compiler is required to make uint8_t an alias of unsigned char. Point 2 is there so that you can cast to uint8_t safely, which some cryptographic code tends to rely on. If uint8_t is just any integer type, there's no safe cast to uint8_t due to strict aliasing rules[1]. That's what I want to fix. CHAR_BITS == 8 if uint8_t exists is just a collateral. [1] https://cellperformance.beyond3d.com/articles/2006/06/understanding-strict-aliasing.html https://cellperformance.beyond3d.com/articles/2006/06/unders...
- boomlinde 8y agoIt follows from the fact that sizeof (char) == 1 and CHAR_BITS >= 8 that sizeof (char) == sizeof (uint8_t), but strictly speaking I don't know that the standard guarantees that uint8_t is an alias of unsigned char and could as well be a distinct type.