[Bug c/92210] New: no warning for invariable used in loop condition
tangyixuan at mail dot dlut.edu.cn
gcc-bugzilla@gcc.gnu.org
Thu Oct 24 13:17:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92210
Bug ID: 92210
Summary: no warning for invariable used in loop condition
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: tangyixuan at mail dot dlut.edu.cn
Target Milestone: ---
There is no warning for an invariable used in loop condition:
$: cat s.c
int main(){
for(int i = 0; i <2;){
}
}
$: gcc-trunk -Wall -Wextra -pedantic -c s.c
gcc version 10.0.0 20191020 (experimental) (GCC)
target: Ubuntu 4.8.5-4ubuntu8~14.04.2
$: clang-trunk -Weverything -pedantic -c s.c
s.c:2:18: warning: variable 'i' used in loop condition not modified in loop
body [-Wfor-loop-analysis]
for(int i = 0; i <2;){
^
1 warning generated.
Is it a better way to report the warning in loop condition, just like the way
Clang does?
More information about the Gcc-bugs
mailing list