File: Underflows.java

package info (click to toggle)
checker-framework-java 3.2.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 22,840 kB
  • sloc: java: 145,910; xml: 839; sh: 518; makefile: 401; perl: 26
file content (41 lines) | stat: -rw-r--r-- 1,070 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import org.checkerframework.common.value.qual.*;

class Underflows {
    static void bytes() {
        byte min = Byte.MIN_VALUE;
        // :: warning: (cast.unsafe)
        @IntVal(127) byte maxPlus1 = (byte) (min - 1);
    }

    static void chars() {
        char min = Character.MIN_VALUE;
        // :: warning: (cast.unsafe)
        @IntVal(65535) char maxPlus1 = (char) (min - 1);
    }

    static void shorts() {
        short min = Short.MIN_VALUE;
        // :: warning: (cast.unsafe)
        @IntVal(32767) short maxPlus1 = (short) (min - 1);
    }

    static void ints() {
        int min = Integer.MIN_VALUE;
        @IntVal(2147483647) int maxPlus1 = min - 1;
    }

    static void longs() {
        long min = Long.MIN_VALUE;
        @IntVal(9223372036854775807L) long maxPlus1 = min - 1;
    }

    static void doubles() {
        double min = Double.MIN_VALUE;
        @DoubleVal(-1.0) double maxPlus1 = min - 1.0;
    }

    static void floats() {
        float min = Float.MIN_VALUE;
        @DoubleVal(-1.0F) float maxPlus1 = min - 1.0f;
    }
}