https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114763
Bug ID: 114763 Summary: Wduplicated-branches just check last else if-else case? Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: hanwei62 at huawei dot com Target Milestone: --- This code: void foo(int x) { if (x) { x -= 2; } else if (x > 50) { x -= 2; } else x += 2; } # gcc -c test.c -Wduplicated-branches not warning, even if-else if branches is same. void foo(int x) { if (x) { x -= 2; } else if (x > 50) { x -= 2; } else if (x < 20) { x += 2; } else { x += 2; } } warning. Same like https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85094 What I find that Wduplicated-branches just check the last `else if-else` branches. https://godbolt.org/z/WP8v5P4Yf It's misleading.