NO

Author Topic: Debug info and maximum speed cause bug  (Read 2216 times)

oog

  • Guest
Debug info and maximum speed cause bug
« on: January 02, 2012, 03:14:39 AM »
I just installed
Setup, 32-bit edition (Release candidate 4)
(for 32-bit Windows 2K/XP/Vista/7) 6.50
and am running it on XP.

The following simple "file copy" program prints an extra character at the beginning if Compiler Debug information is set to Full and Optimizations is Maximum speed (Runtime library is Single-threaded, Assembler and Linker debug info is none). Changing either optimizations to none or compiler debug info to none fixes the problem. I haven't checked other configurations.

Run it like this:
  prog < prog.c > prog2.c
Code: [Select]
#include <stdio.h>

int main() {
    int c = 'T';
    while ((c = getchar()) != EOF)
        putchar(c);
    return 0;
}

czerny

  • Guest
Re: Debug info and maximum speed cause bug
« Reply #1 on: January 02, 2012, 11:31:34 AM »
I can confirm this on w2k. It's a 0x08 char.

czerny

iZzz32

  • Guest
Re: Debug info and maximum speed cause bug
« Reply #2 on: January 02, 2012, 03:58:33 PM »
oog, I confirm too. With debug information turned on it loses one jmp instruction for some reason and so executes the loop body first time before evaluating condition expression. It is a serious bug that affects at least for and while loops. Thank you for the warning:
Code: [Select]
        ; <initialization expression in for loops>

        jmp .cond ; <- this is missing
    .body:
        ; <loop body>

        ; <3rd (increment) expression in for loops>
    .cond:
        ; <condition expression>
        jcc .body