Hi,
I don’t know if it is related with DS or Compiler or somethingelse but i had a problem today.
i skipped the point of comparing int and size_t types in my code.
if(count > strlen(myString1) - strlen(mystring2) )
MyPrintFunc(“count is greater”);
else
MyPrintFunc(“count is less”);
where count=0, strlen(myString1)=12, strlen(myString2)=14 then
I expected if(0 > -2) case will be generated and “count is greater” message will be printed.
But no. It generated if(0 > 2) case. Because strlen return type is size_t which is an unsigned interger. So it always takes possitive number.
This is my simple mispoint. i overlooked the case. But DS did not warm me about it. Shouldnt it warm about similar cases? Or All the responsibilities have been pushed on developers?
Thanks.