| Issue |
173210
|
| Summary |
int x=x idiom causes two clang-analyzer warnings
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
grooverdan
|
gcc unsanctioned idiom of x=x [ref](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36296) causes "core.uninitialized.Assign" + "deadcode.DeadStores"
```c
int warn()
{
int x=x;
x=2;
return x;
}
```
results in:
```
<source>:5:3: warning: Assigned value is uninitialized [core.uninitialized.Assign]
5 | int x=x;
| ^~~~~ ~
<source>:5:7: warning: Value stored to 'x' during its initialization is never read [deadcode.DeadStores]
5 | int x=x;
| ^ ~
2 warnings generated.
Compiler returned: 0
```
These could be seen to cancel each other out and just leave it to the next read of `x` to see if its initialised. I see that on -O0 clang actually creates code for `x=x`. So could the be the analysis is just correct on the IR output.
ref: https://godbolt.org/z/4cYMdoWah
Desired behaviour:
1. change parsing to eliminate the construct at `-O0` so those working around flaws in gcc's uninitialised code path detection can keep the code as is.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs