Skip to content

ArrayContainer.contains(RunContainer) off-by-one error #723

@LeeWorrall

Description

@LeeWorrall

Describe the bug
ArrayContainer.contains(RunContainer) invokes contains(int, int) with an incorrect supremum value, it actually passes the maximum, which can lead to false-positives and false-negatives.

To Reproduce

import org.roaringbitmap.ArrayContainer;
import org.roaringbitmap.Container;
import org.roaringbitmap.RunContainer;

public class Main {
    public static void main(String[] args) {
        Container ac = new ArrayContainer().add(0,10);

        // Case1: should be true, but is false
        Container subset = new RunContainer().add(5,6);
        System.out.println(ac.contains(subset));

        // Case2: should be false, but is true
        Container rc = new RunContainer().add(5,11);
        System.out.println(ac.contains(rc));
    }
}

If you fail to provide the necessary information for us to reproduce the issue, we may reject your bug report.

RoaringBitmap version: 1.0.6

Java version: openjdk version "21.0.3" 2024-04-16 LTS

PR to follow with fix and the above cases covered by additional unit-tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions