I have a section of code that can be summarised as follows;
void MyFunc()
{
int x;
'
'
x;
'
'
}
I would have thought that simply referencing a variable, without modifying it in anyway or using its value in anyway should generate a warning. In VS2003 it does neither, and it I need lint to pick it up.
I realise it doesn't effect execution, but since it is a piece of code that does nothing, and the programmer doubtless intended to do something, why is it not flagged?
Similarly would you expect x = x to be a warning?
Edit: Modified question, as this constitutes a good candidate for a warning, but is not an error. Replies suggest this is handled better with other compilers. Will try out VS2008 later and post result.