I suspect that a bug may be introduced here. ptrdiff_t should be used here instead