fix negative-index warning on empty slices