Is there a way of guarding against the resulting binary from the code in this question? Ideally by way of an error at compile time. Example code from the question:
unsigned int nVal = 0;
nVal = -5; // no error!
If you are using g++, the switch -Wsign-conversion
will warn about the conversion, and -Werror
will make that warning an error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With