mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-22 07:09:03 +00:00
Avoid some undefined behavior in test_bruteforce. (#2400)
* Ulp_Error*: ilogb(reference) - 1 may overflow if reference is zero. * binary_i_double Test: DoubleFromUInt32's result is a cl_double and the attempt is to store it as a cl_double, but p was defined as a pointer to cl_ulong, resulting in an unintended implicit conversion that is not valid for out-of-range doubles. * exp2, tanpi: ensure early exit for NaN. * shift_right_sticky_128: avoid out-of-range shift if shift value is exactly 64. * scalbn: e += n may overflow if n is large, move it after the check for large n.
This commit is contained in:
@@ -1330,8 +1330,7 @@ float Bruteforce_Ulp_Error_Double(double test, long double reference)
|
||||
|
||||
// reference is a normal power of two or a zero
|
||||
// The unbiased exponent of the ulp unit place
|
||||
int ulp_exp =
|
||||
DBL_MANT_DIG - 1 - std::max(ilogbl(reference) - 1, DBL_MIN_EXP - 1);
|
||||
int ulp_exp = DBL_MANT_DIG - std::max(ilogbl(reference), DBL_MIN_EXP);
|
||||
|
||||
// allow correctly rounded results to pass through unmolested. (We might add
|
||||
// error to it below.) There is something of a performance optimization here
|
||||
|
||||
Reference in New Issue
Block a user