https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119544
Bug ID: 119544 Summary: gcc does not figure out variable is unused when incremented in while loop Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: peter0x44 at disroot dot org Target Milestone: --- the following code: https://gcc.godbolt.org/z/n36orPTGE extern char* str; void foo(void) { int i = 0; while (*str == ' ' || *str == '\t' || *str == '\n' || *str == '\r') { i++; str++; } } when compiled with gcc -Wall -Wextra -Wunused-variable does not report that i is unused. Clang does report this, however: <source>:5:6: warning: variable 'i' set but not used [-Wunused-but-set-variable] 5 | int i = 0; | ^