Re:A critique of "How to C in 2016"
by lmm on Friday January 15, 2016 @10:12AM
(#10909721)
> int16_t is also unportable as he mentions later
It's theoretically unportable. I have yet to see a real system to which it's unportable.
> What risk? Please explain how int introduces undefined behaviour.
(Signed) integer overflow is undefined behaviour. It is very common to develop on platforms on which int is 32 or 64-bits. This carries a high risk of accidentally overflowing the limits of a 16-bit integer and not realizing. When you do this you don't notice anything (because it doesn't show up on your development machines), but you've introduced undefined behaviour that can easily manifest in practice on machines with 16-bit int.
It's theoretically unportable. I have yet to see a real system to which it's unportable.
> What risk? Please explain how int introduces undefined behaviour.
(Signed) integer overflow is undefined behaviour. It is very common to develop on platforms on which int is 32 or 64-bits. This carries a high risk of accidentally overflowing the limits of a 16-bit integer and not realizing. When you do this you don't notice anything (because it doesn't show up on your development machines), but you've introduced undefined behaviour that can easily manifest in practice on machines with 16-bit int.