How easy to Create bug with unsigned/NSUInteger in C/C++ and Objective-C
unsigned num = 10;
int negative = -10;
if(negative < num)
cout << "Ok"<< endl;
else
cout << "Bug" << endl;
unsigned n = 0;
cout << "n-1=" << n-1<< endl;
if(n - 1 < 0)
cout << "Ok" << endl;
else
cout << "Bug" << endl;
std::vector < int> v1 = {};
for(unsigned i=0; i < v1.size()-1; i++){
cout << "v1[" << i << "]=" << v1[i] << endl;
}
for(size_t i=0; i < v1.size()-1; i++){
cout << "v1[" << i << "]=" << v1[i] << endl;
}
Unsigned int and abs() function, abs() is not defined in Unsigned int type
vector v1 = {1, 2};
vector v2 = {1, 2, 3};
unsigned int x = abs(v1.size(), v2.size());
// Compiler ERROR: call ambiguous abs()