2 ms·
You're assuming `int` is 32-bits. The fact that C implicitly promotes to `int` makes it extremely hard to use the stdint.h typedefs without accidentally making
by dgrunwald 5y ago
You're assuming `int` is 32-bits.
The fact that C implicitly promotes to `int` makes it extremely hard to use the stdint.h typedefs without accidentally making platform-specific assumptions.
uint16_t a, b, c;
a = 50000;
b = 40000;
c = a * b;
This simple code may or may not have undefined behavior depending on the target platform. (it's fine for 16-bit int, UB for 32-bit int, and fine again for 64-bit int)
Numeric promotion means that it's almost impossible to write code that is correct on multiple platforms with different sizeof(int).
- p0nce 5y agoWell there is the integer promotion issue, and the integers-have-unknown-size issue.