xc-basic3 icon indicating copy to clipboard operation
xc-basic3 copied to clipboard

Unused functions confuse optimizer

Open orlof opened this issue 2 years ago • 6 comments

I was trying to implement joystick reading, but my program crashed. Here is the minimal code that still crashes and can demonstrate the problem. (I cloned the latest xcbasic today).

TYPE Joystick
    SUB Update() STATIC
    END SUB

    SUB WaitClick() STATIC
        DO
            CALL THIS.Update()
        LOOP
    END SUB

    FUNCTION XAxis AS INT() STATIC
        RETURN 0
    END FUNCTION
END TYPE

DIM Joy2 AS Joystick SHARED

PRINT Joy2.XAxis()

orlof avatar Aug 19 '23 12:08 orlof

I can't test it right now but can you try with RETURN CINT(0)?

neilsf avatar Aug 19 '23 12:08 neilsf

That has no effect. The funny thing is that if I remove Update call from WaitClick then XAxis call will work (Update and WaitClick are not even called).

orlof avatar Aug 19 '23 12:08 orlof

...also without optimizer it seems to work

orlof avatar Aug 19 '23 13:08 orlof

It's a bug in the optimizer. I'll fix that.

neilsf avatar Aug 19 '23 13:08 neilsf

A temporary solution is to remove functions that aren't called.

neilsf avatar Aug 19 '23 17:08 neilsf

Same problem here! Please support. Thanks.

AGPX avatar Jan 22 '24 22:01 AGPX