c++ - Lack of warnings on loop counter -


I'm having trouble understanding why the following code does not warn:

  Unsigned test = 0xffffffff; For (unsigned char I = 0; i   

This is in Visual Studio 2010, but GCC is apparently either Does anyone know the warning?

From a language perspective, there is nothing to warn about it i to unsigned int in & lt; is evaluated. And it's perfectly well defined to grow a unsigned char that it wraps around zero.

The fact that this code bothers is unfortunate but it is not clear what rule the compiler will need to implement to find such an object.

Thank you for @ing in the comments below: You can meet GCC to warn about the fact that this comparison is using the flag Always evaluate on the right.

Update 2: Obviously the above option does not work in this case (I do not have a 'modern version of GCC' ...) < / Div>

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -