I have a section of code that can be summarized as follows:
void MyFunc() { int x; ' ' x; ' ' }
I would think that just referring to a variable without changing it in any way or using its value should generate a warning in any case. In VS2003, it does nothing, and I need to pick it up.
I understand that this does not affect execution, but since it is a piece of code that does nothing, and the programmer undoubtedly intended to do something, why is it not marked?
Similarly, would you expect x = x to be a warning?
Edit: The amended question as this is a good candidate for a warning, but not a mistake. The answers show that other compilers are better off. Try VS2008 later and post the result.
c ++ compiler-warnings
Shane maclaughlin
source share