I'm using MS Visual Studio 2017 and (as expected) I get the compiler warning:
Warning C4244 '=': conversion from 'unsigned long' to 'unsigned short', possible loss of data
on this C++ code:
unsigned long test32{70000};
unsigned short test16;
test16 = test32;
However, when I use the cstdint typedefs:
uint32_t test32{70000};
uint16_t test16;
test16 = test32;
...I don't get any compiler warnings at all. Why?
Furthermore, as a strictly-typed language, shouldn't a C++ compiler be giving me errors instead of warnings for either of these approaches (and force me to explicitly cast the 32-bit value to 16-bits prior to assignment in the third line)?