Hi, While running the LTP testsuite on my AVR32 system, I noticed that the times03 testcase never completed even after several hours. Dumping the registers and disassembling showed that it was stuck in work(), on an unconditional jump back to itself, i.e. an infinite loop.
Looking at the code, this is a perfectly reasonable thing for the compiler to do: int timeout; /* Did we timeout in alarm() ? */ (...) void work(void) { int i, j, k; while (!timeout) for (i = 0; i < 10000; i ++) for (j = 0; j < 100; j ++) k = i * j; timeout = 0; } Since "timeout" isn't volatile and there are no barriers in the loop, gcc correctly determined that there's nothing that can ever make the loop terminate, so it generated the smallest possible code: a single rjmp instruction. What's the correct way to fix this? Making timeout a volatile or adding a barrier? Also, since the result of the calculation is never used, no code is ever generated for the two for loops. What's the point of that calculation anyway? Haavard ------------------------------------------------------------------------- SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list