Bug not detected RSPEC-2183

Hi Sonarqube Team,

The code below seems to contain the bug described in RSPEC-2183, however, the bug was not being detected during the scan. Any thoughts?

class BitShiftExample {
    public int showBugInt(int value, int shiftBy) {
        int result = value << shiftBy;more than their number of bits-1
        return result;
    }
    public long showBugLong(long value, int shiftBy) {
        long result = value << shiftBy; 
        return result;
    }
    public static void main(String[] args) {
        BitShiftExample example = new BitShiftExample();
        
        int intResult = example.showBugInt(1, 32); 
        System.out.println("Int shift result (1 << 32): " + intResult);
        long longResult = example.showBugLong(1L, 64); 
        System.out.println("Long shift result (1 << 64): " + longResult);
    }
}

Sonarqube version 25.5
Lang: Java
SonarScanner version: 5.0.1.3006

Screenshot of code scan results

1 Like

Hello, thanks for the multiple reports.

I have created this ticket to group them up and keep track of them. We will investigate them as soon as we have the capacity for it!

Have a good day :slight_smile: