> I think this program should not terminate at all because i will 
> always be one greater than oldi.
> I think gcc3.0 has a problem with no optimization then but since 
> there is later version that works gcc 3.1.1, upgrade.
> 
> Thanks,
> Andrew Pinski
> 

Agreed. Infact it doesn't terminate on all the systems I've tried (3).
But for the sake of presenting a test case :)

---
Test System: Dell XPS-T 450Mhz PIII (Debian testing/unstable)
---
Reading specs from /usr/lib/gcc-lib/i386-linux/3.0.4/specs
Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,objc 
--prefix=/usr --infodir=/share/info --mandir=/share/man --enable-shared 
--with-gnu-as --with-gnu-ld --with-system-zlib --enable-long-long --enable-nls 
--without-included-gettext --disable-checking --enable-threads=posix 
--enable-java-gc=boehm --with-cpp-install-dir=bin --enable-objc-gc i386-linux
Thread model: posix
gcc version 3.0.4
---

[EMAIL PROTECTED]:~$ cat test.c 
main() {                                                                        
                              int i=0;                                          
                                                      int oldi=0;;              
                                                                              
while(++i>oldi) oldi=i;                                                         
                        return oldi;                                            
                                          }                 
[EMAIL PROTECTED]:~$ gcc-3.0 -O0 -o test test.c
[EMAIL PROTECTED]:~$ ./test
(Attach gdb, look at stuff, it's not stopping) ^C
[EMAIL PROTECTED]:~$ gcc-3.0 -o test test.c
[EMAIL PROTECTED]:~$ ./test
(Attach gdb, look at stuff, it's not stopping) ^C
---

Maybe you've been bad to your gcc ;)

In the optimized case (-O9) I see:
080483f8 <main>:
 80483f8:       55                      push   %ebp
 80483f9:       89 e5                   mov    %esp,%ebp
 80483fb:       83 ec 08                sub    $0x8,%esp
 80483fe:       83 e4 f0                and    $0xfffffff0,%esp
 8048401:       8d 76 00                lea    0x0(%esi),%esi
 8048404:       eb fe                   jmp    8048404 <main+0xc>
 8048406:       90                      nop    
 8048407:       90                      nop    

Which never terminates... and gcc knew it.

If there were some examples of gcc-3.0 mucking 
up optimizations... this isn't it.

c.


Reply via email to