[Bug c/59812] New: Missing aggressive loop optimization warning
ppluzhnikov at google dot com
gcc-bugzilla@gcc.gnu.org
Tue Jan 14 18:08:00 GMT 2014
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59812
Bug ID: 59812
Summary: Missing aggressive loop optimization warning
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: ppluzhnikov at google dot com
Google ref: b/12015772
The following source:
int x[4];
int foo (int a)
{
int n = a ? 1 : 2;
int i;
for(i = 0; i < 4 + n; i++ )
x[i]++;
return 0;
}
compiles into infinite loop due to aggressive loop optimization,
but produces no warnings with
g++ (GCC) 4.9.0 20140110 (experimental)
g++ -c -O2 -Wall -Wextra t.c && objdump -d t.o
t.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <_Z3fooi>:
0: b8 00 00 00 00 mov $0x0,%eax
5: 83 00 01 addl $0x1,(%rax)
8: 48 83 c0 04 add $0x4,%rax
c: eb f7 jmp 5 <_Z3fooi+0x5>
It would be much nicer to end-user to emit compile time warning here.
More information about the Gcc-bugs
mailing list