bugprone-redundant-branch-condition incorrectly marks a condition as redundant
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
```c++
int f();
void g();
void h(bool b)
{
if (b)
{
for (int i = 0; i < 3; ++i)
{
switch (f())
{
case 4:
case 5:
if (b) // Redundant condition 'b' [bugprone-redundant-branch-condition]
{
b = false;
g();
}
break;
}
}
}
}
```
https://gcc.godbolt.org/z/TqxoT9PYz
Contributor guide
Research direction
Start at the bugprone-redundant-branch-condition checker and reproduce the false positive with the C++ example from the issue, using the linked Compiler Explorer case as a reference. Trace why the inner condition on b is considered redundant despite the loop and switch, then add a regression test and confirm that this condition is no longer diagnosed without breaking existing checks.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100