#1253 function return value mismatch

closed-fixed
Maarten Brock
5
2013-05-25
2006-12-05
Maarten Brock
No

Compiling the following code generates two warnings and finally broken code:

typedef char * PCHAR;

char KAR;

PCHAR foo(void) reentrant //this fails
{
return &KAR;
}

PCHAR bar(void) // this is ok
{
return &KAR;
}

sdcc -c bug.c

bug.c:7: warning 60: function return value mismatch from type 'char near* '
to type 'char generic* unknown type'
bug.c:5: warning 59: function 'foo' must return value

Used SDCC 2.6.1 #4471

;------------------------------------------------------------
; bug.c:5: PCHAR foo(void) reentrant //this fails
; -----------------------------------------
; function foo
; -----------------------------------------
_foo:
; bug.c:7: return &KAR; <<<<< NO CODE GENERATED
; Peephole 300 removed redundant label 00101$
ret
;------------------------------------------------------------
;Allocation info for local variables in function 'bar'
;------------------------------------------------------------
;------------------------------------------------------------
; bug.c:10: PCHAR bar(void) // this is ok
; -----------------------------------------
; function bar
; -----------------------------------------
_bar:
; bug.c:12: return &KAR;
; genRet
; Peephole 182.a used 16 bit load of DPTR
mov dptr,#_KAR
mov b,#0x40
; Peephole 300 removed redundant label 00101$
ret

Discussion

  • Maarten Brock
    Maarten Brock
    2006-12-06

    Logged In: YES
    user_id=888171
    Originator: YES

    Fixed in SDCC 2.6.2 #4503.

     
  • Maarten Brock
    Maarten Brock
    2006-12-06

    • milestone: --> fixed
    • assigned_to: nobody --> maartenbrock
    • status: open --> closed-fixed