Converting from double to an integer type changes the value "by design" (think about 3.141592654 converted to int ).
Converting from long int to int instead can either work or may be undefined depending on the platform and value (the only guarantee is that int no bigger than long int , but they can be the same size).
In other words, conversion problems between integer types are random implementation artifacts, not design decisions. A warning about them is better, especially if it can be detected at compile time , because of these limitations, something is not working.
Note that even converting from double to int is legal and well-defined (if done within the boundaries), and implementation is not required to warn about this, even when loss of accuracy can be seen at compile time. Compilers that warn too much, even when usage can be significant, can be a problem (you just turn off warnings or get even worse the habit of accepting an unclean build as usual).
These implicit conversion rules can add up to other C ++ wrinkles that become really weird and difficult to justify for behaviors such as:
std::string s; s = 3.141592654;
Do not try to use too much logic with C ++. Reading characteristics work better.
6502
source share