[tests] numeric overflow inspection test migrated

This commit is contained in:
Roman Shevchenko
2016-04-08 19:41:24 +02:00
parent 6446aca066
commit 9d4ff8c389
4 changed files with 112 additions and 749 deletions
@@ -0,0 +1,88 @@
// overflows in const expressions
class c {
// @*#$& ! references do not work in JRE
static final long LONG_MIN_VALUE = 0x8000000000000000L;
static final long LONG_MAX_VALUE = 0x7fffffffffffffffL;
static final int INTEGER_MIN_VALUE = 0x80000000;
static final int INTEGER_MAX_VALUE = 0x7fffffff;
static final float FLOAT_MIN_VALUE = 1.4e-45f;
static final float FLOAT_MAX_VALUE = 3.4028235e+38f;
static final double DOUBLE_MIN_VALUE = 4.9e-324;
static final double DOUBLE_MAX_VALUE = 1.7976931348623157e+308;
void f() {
float f1 = <warning descr="Numeric overflow in expression">1.0f / 0.0f</warning>;
<warning descr="Numeric overflow in expression">f1 = <warning descr="Numeric overflow in expression">FLOAT_MAX_VALUE + FLOAT_MAX_VALUE</warning></warning>;
<warning descr="Numeric overflow in expression">f1 = <warning descr="Numeric overflow in expression">FLOAT_MAX_VALUE * 2</warning></warning>;
<warning descr="Numeric overflow in expression">f1 = <warning descr="Numeric overflow in expression">2 / FLOAT_MIN_VALUE</warning></warning>;
f1 = FLOAT_MIN_VALUE + 1;
f1 = - FLOAT_MIN_VALUE;
f1 = -FLOAT_MAX_VALUE;
System.out.println(f1);
double d1 = <warning descr="Numeric overflow in expression">DOUBLE_MAX_VALUE - -DOUBLE_MAX_VALUE</warning>;
d1 = DOUBLE_MAX_VALUE + 1;
<warning descr="Numeric overflow in expression">d1 = <warning descr="Numeric overflow in expression">2 * DOUBLE_MAX_VALUE</warning></warning>;
<warning descr="Numeric overflow in expression">d1 = <warning descr="Numeric overflow in expression">2 / DOUBLE_MIN_VALUE</warning></warning>;
<warning descr="Numeric overflow in expression">d1 = <warning descr="Numeric overflow in expression">2 / 0.0d</warning></warning>;
<warning descr="Numeric overflow in expression">d1 = <warning descr="Numeric overflow in expression">2 / 0.0</warning></warning>;
System.out.println(d1);
int i1 = <warning descr="Numeric overflow in expression">INTEGER_MAX_VALUE + 1</warning>;
<warning descr="Numeric overflow in expression">i1 = <warning descr="Numeric overflow in expression">INTEGER_MAX_VALUE - 1 + 2</warning></warning>;
<warning descr="Numeric overflow in expression">i1 = <warning descr="Numeric overflow in expression">INTEGER_MAX_VALUE - INTEGER_MIN_VALUE</warning></warning>;
<warning descr="Numeric overflow in expression">i1 = <warning descr="Numeric overflow in expression">-INTEGER_MIN_VALUE</warning></warning>;
<warning descr="Numeric overflow in expression">i1 = <warning descr="Numeric overflow in expression">INTEGER_MIN_VALUE - 1</warning></warning>;
<warning descr="Numeric overflow in expression">i1 = <warning descr="Numeric overflow in expression">INTEGER_MIN_VALUE - INTEGER_MAX_VALUE</warning></warning>;
i1 = INTEGER_MIN_VALUE + INTEGER_MAX_VALUE;
i1 = - INTEGER_MAX_VALUE;
i1 = - -INTEGER_MAX_VALUE;
<warning descr="Numeric overflow in expression">i1 = <warning descr="Numeric overflow in expression">INTEGER_MIN_VALUE * -1</warning></warning>;
<warning descr="Numeric overflow in expression">i1 = <warning descr="Numeric overflow in expression">INTEGER_MIN_VALUE * 2</warning></warning>;
<warning descr="Numeric overflow in expression">i1 = <warning descr="Numeric overflow in expression">INTEGER_MAX_VALUE * -2</warning></warning>;
i1 = INTEGER_MAX_VALUE * -1;
<warning descr="Numeric overflow in expression">i1 = <warning descr="Numeric overflow in expression">2 / 0</warning></warning>;
<warning descr="Numeric overflow in expression">i1 = <warning descr="Numeric overflow in expression">INTEGER_MIN_VALUE / -1</warning></warning>;
System.out.println(i1);
long l1 = <warning descr="Numeric overflow in expression">LONG_MAX_VALUE + 1</warning>;
<warning descr="Numeric overflow in expression">l1 = <warning descr="Numeric overflow in expression">LONG_MAX_VALUE - 1 + 2</warning></warning>;
<warning descr="Numeric overflow in expression">l1 = <warning descr="Numeric overflow in expression">LONG_MAX_VALUE - LONG_MIN_VALUE</warning></warning>;
<warning descr="Numeric overflow in expression">l1 = <warning descr="Numeric overflow in expression">-LONG_MIN_VALUE</warning></warning>;
<warning descr="Numeric overflow in expression">l1 = <warning descr="Numeric overflow in expression">LONG_MIN_VALUE - 1</warning></warning>;
<warning descr="Numeric overflow in expression">l1 = <warning descr="Numeric overflow in expression">LONG_MIN_VALUE - LONG_MAX_VALUE</warning></warning>;
l1 = LONG_MIN_VALUE + LONG_MAX_VALUE;
l1 = - LONG_MAX_VALUE;
l1 = - -LONG_MAX_VALUE;
<warning descr="Numeric overflow in expression">l1 = <warning descr="Numeric overflow in expression">-INTEGER_MIN_VALUE</warning></warning>;
l1 = -1L + INTEGER_MIN_VALUE;
<warning descr="Numeric overflow in expression">l1 = <warning descr="Numeric overflow in expression">LONG_MIN_VALUE * INTEGER_MIN_VALUE</warning></warning>;
<warning descr="Numeric overflow in expression">l1 = <warning descr="Numeric overflow in expression">LONG_MIN_VALUE * -1</warning></warning>;
<warning descr="Numeric overflow in expression">l1 = <warning descr="Numeric overflow in expression">LONG_MIN_VALUE * 2</warning></warning>;
<warning descr="Numeric overflow in expression">l1 = <warning descr="Numeric overflow in expression">LONG_MAX_VALUE * -2</warning></warning>;
l1 = INTEGER_MIN_VALUE * -1L;
<warning descr="Numeric overflow in expression">l1 = <warning descr="Numeric overflow in expression">2 / 0L</warning></warning>;
<warning descr="Numeric overflow in expression">l1 = <warning descr="Numeric overflow in expression">2 % 0L</warning></warning>;
<warning descr="Numeric overflow in expression">l1 = <warning descr="Numeric overflow in expression">LONG_MIN_VALUE / -1</warning></warning>;
<warning descr="Numeric overflow in expression">l1 = <warning descr="Numeric overflow in expression">30 * 24 * 60 * 60 * 1000</warning></warning>;
<warning descr="Numeric overflow in expression">l1 = <warning descr="Numeric overflow in expression"><warning descr="Numeric overflow in expression">30000000 * 243232323 * <warning descr="Numeric overflow in expression">(<warning descr="Numeric overflow in expression">LONG_MAX_VALUE +3</warning>)</warning></warning> / 5</warning></warning>;
System.out.println(l1);
}
private static final long MILLIS_PER_DAY = 24 * 3600 * 1000;
private static final long _7DAYS = 7 * MILLIS_PER_DAY;
private static final long _30DAYS = 30 * MILLIS_PER_DAY;
private static final long _1000DAYS = 1000 * MILLIS_PER_DAY;
{
System.out.println(_1000DAYS + _30DAYS + _7DAYS);
}
int iii = <warning descr="Numeric overflow in expression">2 % 0</warning>;
}
@@ -1,650 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>Foo.java</file>
<line>87</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>16</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>17</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>17</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>18</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>18</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>19</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>19</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>25</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>27</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>27</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>28</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>28</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>29</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>29</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>30</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>30</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>34</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>35</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>35</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>36</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>36</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>37</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>37</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>38</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>38</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>39</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>39</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>43</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>43</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>44</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>44</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>45</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>45</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>47</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>47</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>48</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>48</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>51</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>52</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>52</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>53</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>53</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>54</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>54</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>55</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>55</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>56</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>56</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>60</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>60</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>62</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>62</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>63</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>63</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>64</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>64</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>65</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>65</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>67</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>67</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>68</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>68</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>69</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>69</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>71</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>71</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>72</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>72</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>72</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>72</line>
<description>Numeric overflow in expression</description>
</problem>
<problem>
<file>Foo.java</file>
<line>72</line>
<description>Numeric overflow in expression</description>
</problem>
</problems>
@@ -1,88 +0,0 @@
// overflows in const expressions
class c {
// @*#$& ! references do not work in JRE
static final long LONG_MIN_VALUE = 0x8000000000000000L;
static final long LONG_MAX_VALUE = 0x7fffffffffffffffL;
static final int INTEGER_MIN_VALUE = 0x80000000;
static final int INTEGER_MAX_VALUE = 0x7fffffff;
static final float FLOAT_MIN_VALUE = 1.4e-45f;
static final float FLOAT_MAX_VALUE = 3.4028235e+38f;
static final double DOUBLE_MIN_VALUE = 4.9e-324;
static final double DOUBLE_MAX_VALUE = 1.7976931348623157e+308;
void f() {
float f1 = 1.0f / 0.0f;
f1 = FLOAT_MAX_VALUE + FLOAT_MAX_VALUE;
f1 = FLOAT_MAX_VALUE * 2;
f1 = 2 / FLOAT_MIN_VALUE;
f1 = FLOAT_MIN_VALUE + 1;
f1 = - FLOAT_MIN_VALUE;
f1 = -FLOAT_MAX_VALUE;
System.out.println(f1);
double d1 = DOUBLE_MAX_VALUE - -DOUBLE_MAX_VALUE;
d1 = DOUBLE_MAX_VALUE + 1;
d1 = 2 * DOUBLE_MAX_VALUE;
d1 = 2 / DOUBLE_MIN_VALUE;
d1 = 2 / 0.0d;
d1 = 2 / 0.0;
System.out.println(d1);
int i1 = INTEGER_MAX_VALUE + 1;
i1 = INTEGER_MAX_VALUE - 1 + 2;
i1 = INTEGER_MAX_VALUE - INTEGER_MIN_VALUE;
i1 = -INTEGER_MIN_VALUE;
i1 = INTEGER_MIN_VALUE - 1;
i1 = INTEGER_MIN_VALUE - INTEGER_MAX_VALUE;
i1 = INTEGER_MIN_VALUE + INTEGER_MAX_VALUE;
i1 = - INTEGER_MAX_VALUE;
i1 = - -INTEGER_MAX_VALUE;
i1 = INTEGER_MIN_VALUE * -1;
i1 = INTEGER_MIN_VALUE * 2;
i1 = INTEGER_MAX_VALUE * -2;
i1 = INTEGER_MAX_VALUE * -1;
i1 = 2 / 0;
i1 = INTEGER_MIN_VALUE / -1;
System.out.println(i1);
long l1 = LONG_MAX_VALUE + 1;
l1 = LONG_MAX_VALUE - 1 + 2;
l1 = LONG_MAX_VALUE - LONG_MIN_VALUE;
l1 = -LONG_MIN_VALUE;
l1 = LONG_MIN_VALUE - 1;
l1 = LONG_MIN_VALUE - LONG_MAX_VALUE;
l1 = LONG_MIN_VALUE + LONG_MAX_VALUE;
l1 = - LONG_MAX_VALUE;
l1 = - -LONG_MAX_VALUE;
l1 = -INTEGER_MIN_VALUE;
l1 = -1L + INTEGER_MIN_VALUE;
l1 = LONG_MIN_VALUE * INTEGER_MIN_VALUE;
l1 = LONG_MIN_VALUE * -1;
l1 = LONG_MIN_VALUE * 2;
l1 = LONG_MAX_VALUE * -2;
l1 = INTEGER_MIN_VALUE * -1L;
l1 = 2 / 0L;
l1 = 2 % 0L;
l1 = LONG_MIN_VALUE / -1;
l1 = 30 * 24 * 60 * 60 * 1000;
l1 = 30000000 * 243232323 * (LONG_MAX_VALUE +3) / 5;
System.out.println(l1);
}
private static final long MILLIS_PER_DAY = 24 * 3600 * 1000;
private static final long _7DAYS = 7 * MILLIS_PER_DAY;
private static final long _30DAYS = 30 * MILLIS_PER_DAY;
private static final long _1000DAYS = 1000 * MILLIS_PER_DAY;
{
System.out.println(_1000DAYS + _30DAYS + _7DAYS);
}
int iii = 2 % 0;
}