This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

egcs-current: Major optimizer bug


egcs-2.91.45 19980628 (gcc2 ss-980609 experimental) severely miscompiles
the following, quite simple, code:

>>>>>>>>>>>>>>>>
int dn_skipname(unsigned char *ptr, unsigned char *eom) {
    unsigned char *saveptr = ptr;

    if (ns_name_skip(&ptr, eom) == -1)
	        return (-1);
    return (ptr - saveptr);
}
>>>>>>>>>>>>>>>>

The resulting assembly output (i386) looks like the following. As you can
see, it will always return zero, which is not at all what's intended.  :-(

   0:   55              pushl  %ebp
   1:   89 e5           movl   %esp,%ebp
   3:   8b 45 0c        movl   0xc(%ebp),%eax
   6:   50              pushl  %eax
   7:   8d 55 08        leal   0x8(%ebp),%edx
   a:   52              pushl  %edx
   b:   e8 fc ff ff ff  call   c <dn_skipname+0xc>
  10:   83 f8 ff        cmpl   $0xffffffff,%eax
  13:   74 0b           je     20 <dn_skipname+0x20>
  15:   8b 45 08        movl   0x8(%ebp),%eax
  18:   89 c2     ?**?  movl   %eax,%edx
  1a:   29 c2     ?**?  subl   %eax,%edx
  1c:   89 d0           movl   %edx,%eax
  1e:   eb 05           jmp    25 <dn_skipname+0x25>
  20:   b8 ff ff ff ff  movl   $0xffffffff,%eax
  25:   89 ec           movl   %ebp,%esp
  27:   5d              popl   %ebp
  28:   c3              ret    

Compiling without -O fixes the problem.

Somebody please add a testcase, and/or fix the bug (it was introduced
sometime between 2.91.02 and 2.91.30; sorry I can't pinpoint it better).

Thanks.

-- 
Matthias Urlichs
noris network GmbH


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]