Hi Andreas,
I had a quick look at the generated assemble code for a PIC16.
In your first code example the code is (I changed 3 times i into i, j and k so I could compile it):
; 10 i=test1()
movlw 0
movwf v_i
; 11 if i>0 & i<13 then
movf v_i,w
bsf v__bitbucket, 0 ; _btemp1
btfsc v__status, v__z
In your last code example where you removed the function the code is:
clrf v_k
; 35 if k>0 & k<13 then
movf v_k,w
bsf v__bitbucket, 6 ; _btemp7
btfsc v__status, v__z
If I am right - and I hope I am not - the first piece of code does not work because the Z flag (v__z) of the status register (v__status) is never affected by any of these instructions. In the last code example the clrf instruction sets the Z flag.
In other words, moving the return value of 0 to v_i is not the same as clearing the value of v_k. So it might be a compiler bug. I wonder why it has not been discovered before.
Still need to see if my draft conclusion is correct.
Kind regards,
Rob