#501 generic pointer increment ignored

closed-fixed
Johan Knol
None
5
2013-05-25
2003-04-13
Josef Pavlik
No

I found that the following sequence is not compiled correctly:

char *p;

a(*p++);
a(*p);

see the attachment

this is an small warning report bug too
bug1.c:4: warning: in function (null) unreferenced function argument : 'x'

bye
Jet

note - seems that the bug is not present always. Sometimes compiles ok, sometimes the result is broken. Maybe an uninitialized variable?
----------------------------------------------------------------------
void a(char x){}
xdata char str[100];

main()
{
char * p;
char x;

p=str;

a(*p++);
a(*p);
/*
for (x=0; x<100; x++)
{
a(*p++);
p++;
}
*/
}

/*
sdcc --version
SDCC : mcs51/gbz80/z80/avr/ds390/pic14/TININative/xa51 2.3.4 (Apr 9 2003) (UNIX)

/usr/local/bin/sdcc --model-small --noinduction -I./ -I/usr/local/share/sdcc/include -I/usr/local/share/sdcc/include/mcs51 -c bug1.c

errorneous warning message:
bug1.c:4: warning: in function (null) unreferenced function argument : 'x'

buggy code generated:

;bug1.c:14: p=str;
;bug1.c:16: a(*p++);
; genPointerGet
; genFarPointerGet
mov dptr,#_str
movx a,@dptr
mov r2,a
inc dptr
; genCall
mov dpl,r2 ; pointer value is lost at this point
lcall _a
;bug1.c:17: a(*p);
; genPointerGet
; genFarPointerGet
mov dptr,#_str ; seems that the compiler things, that p is constant - ignores the increment
movx a,@dptr
mov r2,a
; genCall
mov dpl,r2
lcall _a
00101$:

*/

Discussion

  • Johan Knol
    Johan Knol
    2003-04-17

    • milestone: --> fixed
    • assigned_to: nobody --> johanknol
    • status: open --> closed-fixed
     
  • Johan Knol
    Johan Knol
    2003-04-17

    Logged In: YES
    user_id=63512

    fixed in mcs51/ralloc.c:1.112