-
Bug
-
Resolution: Fixed
-
Medium
-
Code Generation Tools
-
CODEGEN-7715
-
-
-
default
-
Unsigned range check expressions for unsigned integral types larger than int may result in incorrect code. This bug may also manifest with pointer range checks if the size of a pointer is larger than that of an int. The necessary conditions for this bug are:
1. An unsigned integral's value is compared against a lower bound and an upper bound.
2. The lower bound and upper bound values are either constants or are derived from constants.
For example, the attached file has this code to check whether an address is within a certain range.
if ((address_as_ulong < high) && (address_as_ulong >= low))
To build it ...
% cl7x -@options.txt try2.c FILE: try2.obj CODE size (bytes): 256 CONST size (bytes): 56
A simple main routine calls the function with this test three times. Correct output is ...
too_low gives 456 in_range gives 123 too_high gives 456
However, the generated code is wrong, which causes the second call to get a wrong answer. The output actually seen is ...
too_low gives 456 in_range gives 456 too_high gives 456
The problem occurs when --opt_level=1 or higher.