https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100184
Bug ID: 100184
Summary: Detect variables which are only "used" in updating
themselves
Product: gcc
Version: 10.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: eyalroz1 at gmx dot com
Target Milestone: ---
Consider the following C function:
```
int bar()
{
int pow = 1;
return 1;
}
```
If we compile this with -Wall , GCC will warn us of having an unused variable.
If we write:
```
int bar()
{
int pow = 1;
pow = 2;
return 1;
}
```
a different warning: Variable set but not used.
Now, suppose we write:
```
int bar()
{
int pow = 1;
pow++;
return 1;
}
```
we will no longer get any warning. I believe GCC should warn in this case; or
at least - there should be a flag which makes it warn when a variable is used
only in updating itself.