Hard crash when slicing an array down to length zero



  • Another hard crash:

    b = [0]
    c = b[1:-1] // should yield empty array c = [], print(c) would confirm that
    c[len(c)] = 0
    print("c = ", c, "\n")
    

    The crash happens at the print statement, but originally, I observed a hard crash after a [1:-1] slice on a single element array with non-print operations that I could not cook down to a presentable state. Something about the state of c must be wrong right from the start, appending 0 makes it worse, print falls into the trap.
    Making b at the start larger avoids the crash, it only hits if the resulting slice length is 0.

    Workaround: Just init c to an empty array.


Log in to reply