Compile this code with MSVC2005
unsigned short x = 20;
unsigned short y = 20;
for ( unsigned long i = 0; i < x * y ; i++ )
{
cout<<i<<endl;
}
and u get
warning C4018: '<' : signed/unsigned mismatch
why? i mean, it all runs fine, j is iterated till 400 and, as I know, the short unsigned should be converted in an unsigned long when doing the comparison, so no overflow cand be possible ... And, why is it stated signed/unsigned mismatch when all variables are unsigned and no overflow is possible?
thx in advance