Today, I was writing a piece of code when I found out that if I typed a variable's identifier( after defining it ) without doing anything with it, is allowed. Below is a code segment showing what I mean if you don't already.
1 2 3 4 5 6 7 8
int main( )
{
int Variable( 0 );
Variable; // This is what I'm referring to.
return 0;
}
Any statement my stand for itself, just like you can call a function returning a value without actually using the return value. This could be used with cases in which retrieving a value has desirable side effects, but other than that it's just language stuff, because EXPRESSION-SEMICOLON is valid syntax. Most compilers would probably give you a warning that you aren't actually doing anything there.
That's strange, Ne555. -Wall has been enabled for a long time and it never gave me the warning. Is it possible that the compiler is OOD( out-of-date )?