4 ms·
Unless int is 16-bit. Code like this is potentially UB; you should use int32_t as the target.
by Filligree 2y ago
Unless int is 16-bit. Code like this is potentially UB; you should use int32_t as the target.
- kevin_thibedeau 2y agoYou should use long, and don't ever assume it's exactly 32-bits. The fixed size types are often an overused crutch that hampers future portability.
- loeg 2y agoThere are no mainstream 16-bit int platforms. It's fine to know what you target. The promotions that are really surprising are from uint64_t bitfields to int (because it's based on value representability). struct { uint64_t a : 33, b : 15; } s; // s.b gets "promoted" to int, s.a does not