Suppose we have code like this:
int x = 5;
++x; /* line 1.*/
warning: unused variable ‘x’ [-Wunused-variable]
x++ is the same as
x = x+1;, the assignment. When you are assigning to something, you possibly can not skip using it. The result is not discarded.
Also, from the online gcc manual, regarding
Warn whenever a local or static variable is unused aside from its declaration.
So, when you comment the
x++;, it satisfies the condition to generate and emit the warning message. When you uncomment, the usage is visible to the compiler (the "usefulness" of this particular "usage" is questionable, but, it's an usage, nonetheless) and no warning.