------- Comment #3 from nick dot spence at freescale dot com 2008-05-13 19:56 ------- The code has two loops, which compile correctly when no optimization, or -O1 are used, but the second loop becomes infinite if -Os or -O2 is used.
.file "test.c" .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "\n reads %d, 0x%08X" .text .globl main .type main, @function main: leal 4(%esp), %ecx andl $-16, %esp pushl -4(%ecx) pushl %ebp movl %esp, %ebp pushl %esi pushl %ebx xorl %ebx, %ebx pushl %ecx subl $12, %esp .L2: movl $0, (%ebx) addl $4, %ebx cmpl $64, %ebx jne .L2 /* branch condition for first loop */ xorl %esi, %esi .L4: pushl %eax pushl %ebx subl $4, %ebx pushl %esi incl %esi pushl $.LC0 call printf movl (%ebx), %eax addl $16, %esp jmp .L4 /* branch condition for second loop was lost */ .size main, .-main .ident "GCC: (GNU) 4.1.2 20070626 (Red Hat 4.1.2-13)" .section .note.GNU-stack,"",@progbits -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36232