------- Comment #1 from edwintorok at gmail dot com 2008-03-19 18:54 ------- Created an attachment (id=15345) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15345&action=view) testcase
Some observations: If you remove some dead code the optimization bug goes away: Remove either of these and you'll get correct code, for example: if (metadata->chunk_current >= metadata->chunk_end) { } If I remove that if and compare assembly output, I see this: $ diff -wu bad.s ok.s --- bad.s 2008-03-19 20:51:59.000000000 +0200 +++ ok.s 2008-03-19 20:51:47.000000000 +0200 @@ -60,7 +60,7 @@ testb %al, %al js .L9 movsbq %sil,%rax - addq %rax, %rcx + leaq 1(%rcx,%rax), %rcx .L11: movzbl (%rdx), %eax addq $1, %rdx Of course the original code that is miscompiled doesn't have dead code, it is just because of the reduction. If you need more info please ask. This is related to this bug (but that occurs only at -O3): http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=470557 -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35643