Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
for loop iterator being comapred to a variable of another type
#3
(27-11-2021, 09:10 AM)misra-c Wrote: Whether the code is an infinite loop will depend on the value of "var".  If it is less than 255 there is no problem.  If examination of the code shows that "var" may exceed 255 then rule 14.3 would be violated since the controlling expression will always be false.

Thanks for the reply, does this mean that the following code does not violate rule 14.3 : 
Code:
u_int32_t var = var2; // var2 being u_int32_t as well
for (u_int8_t i=0; i<var; i++) ....
as it is not clear whether var/var2 exceeds 255 or not ?
Reply


Messages In This Thread
RE: for loop iterator being comapred to a variable of another type - by ZESS - 14-12-2021, 08:43 AM

Forum Jump:


Users browsing this thread: 2 Guest(s)