[Bug c++/104635] New: for loop optimized into infinite loop
szullo.adam at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Feb 22 10:49:28 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104635
Bug ID: 104635
Summary: for loop optimized into infinite loop
Product: gcc
Version: 11.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: szullo.adam at gmail dot com
Target Milestone: ---
compiling with g++, optimization (other than -O0) turn for loop into infinite
loop
#include <stdio.h>
int test()
{
for (int i=0; i<4; i++)
{
printf("%d\n",i);
}
}
int main()
{
test();
}
i DO ACKNOWLEDGE, that (contrary to c) in c++ missing return value is invalid
(-Wreturn-type)
Expected behaviour:
return with garbage value
-or-
segfault on return
// or maybe instead of warning, throw error
More information about the Gcc-bugs
mailing list