this bug is related to casting the built-in strlen() function to a signed or
unsigned char where the pointer is on the stack.


This is the correct code generated....
    signed char *cp;
    signed int size;

    size = strlen(cp);



     mov 14(r1), r10   ;   cp,  size
     dec r10  ;   size
.L__strlenhi__480:
     inc r10  ;   size
     tst.b 0(r10)  ;   size
     jne .L__strlenhi__480
     sub 14(r1), r10  ;   cp,  size




This is what you get with a signed char as destination...
    signed char *cp;
    signed char size;

    size = strlen(cp);

     mov 14(r1), r15   ;   cp
     dec r15
.L__strlenhi__483:
     inc r15
     tst.b 0(r15)
     jne .L__strlenhi__483
     mov.b r15, r11  ;   size
     sub.b 14(r1), r11  ;   cp,  size

the buffer is at address 1d7a and the buffer has one char in it.
    0x7b - 0x1d = 94 !!

The difference between them is a length of 94 & 2 (in my case)


--

Simon Peacock                                                              |
www.harvest.com

Harvest Electronics, PO Box 446                                | Ph  (+64 6)
370 1991

10 Pragnell st, Masterton 5810, NEW ZEALAND   | fax (+64 6) 370 1993

Reply via email to