Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArrayIndexOutOfBoundsException in the iterator of subList of the IntImmutableList #321

Open
MartinTunzer-TomTom opened this issue Jun 7, 2024 · 1 comment

Comments

@MartinTunzer-TomTom
Copy link

Version 8.5.12
How to reproduce:

IntList list = new IntArrayList();
list.add(1);
list.add(2);
list.add(3);

list = new IntImmutableList(list);

IntList subList = list.subList(1, 3);

for (int i : subList) {
    System.out.println("i = " + i);
}

gives:

i = 2
i = 3
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 3 out of bounds for length 3
	at it.unimi.dsi.fastutil.ints.IntImmutableList$ImmutableSubList$1.nextInt(IntImmutableList.java:483)
	at it.unimi.dsi.fastutil.ints.IntIterator.next(IntIterator.java:46)
	at it.unimi.dsi.fastutil.ints.IntListIterator.next(IntListIterator.java:103)
	at it.unimi.dsi.fastutil.ints.IntListIterator.next(IntListIterator.java:31)
@vigna
Copy link
Owner

vigna commented Jun 10, 2024

This should be fixed in the GitHub code. Can you check whether this is the case ? I'm gonna do a release ASAP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants