A bit of googling revealed that above warning can be dangerous. To understand the underlying problem, here is my own version of INT_MIN.
#define INT32_MIN -2147483648
As 2147483648 is greater than max 32-bit signed int value (MAX_INT), it is treated as unsigned int
if ( 1 > INT32_MIN ) // comparing two unsigned values
std::cout << "I am sure, 1 gt INT32_MIN";
else
std::cout << "Surprse! it says, 1 lt INT32_MIN";
#define INT32_MIN (-2147483647 - 1) // don't forget to put the braces around
1. More detailed explanation is available here
2.
No comments:
Post a Comment