------- Comment #1 from nicolas at dyalog dot com 2007-09-03 12:26 ------- Created an attachment (id=14153) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14153&action=view) preprocessed source of a repro
Sorry guys the repro is a bit complicated but i could NOT narrow it down any further. I can't understand what triggers this optimizer bug. I refer to the optimized version when compiled with : gcc delayopt.i -o delayopt -O3 -ggdb3 -Wall And to the debug version when compiled with : gcc delayopt.i -o delayopt -ggdb3 -Wall The function that the optimizer skips is TimeValToFileTime(). If you look at the optimized disassembly, you will see that asyncSleep() does the follwing routine which is the optimized call to TimeValToFileTime() : 400675: imul $0x989680,%rax,%rax 40067c: lea (%rbx,%rbx,4),%rbx 400680: lea (%rax,%rbx,2),%rbx whereas nt_async_delay() doesn't and therefore uses a bad value for the variable "curr". Output of optimized version : Going to sleep 1.000000 seconds Slept -1188821606.219786 seconds Output of debug version : Going to sleep 1.000000 seconds Slept 1.004632 seconds -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33292