mirror of
https://github.com/HDFGroup/hdf5.git
synced 2024-11-27 02:10:55 +08:00
Fix undefined left shifting of negative numbers (#338)
Undefined Bahavior Sanitizer errored here about left shifting negative numbers.
This commit is contained in:
parent
0a2a385acc
commit
5f015f4742
@ -4041,7 +4041,7 @@ test_nbit_compound_2(hid_t file)
|
||||
power = HDpow(2.0F, (double)(precision[1] - 1));
|
||||
orig_data[i][j].a.c = (char)(((long long)HDrandom() % (long long)power) << offset[1]);
|
||||
power = HDpow(2.0F, (double)(precision[2] - 1));
|
||||
orig_data[i][j].a.s = (short)(-((long long)HDrandom() % (long long)power) << offset[2]);
|
||||
orig_data[i][j].a.s = (short)(-(((long long)HDrandom() % (long long)power) << offset[2]));
|
||||
orig_data[i][j].a.f = float_val[i][j];
|
||||
|
||||
power = HDpow(2.0F, (double)precision[3]);
|
||||
@ -4057,7 +4057,7 @@ test_nbit_compound_2(hid_t file)
|
||||
for (n = 0; n < (size_t)array_dims[1]; n++) {
|
||||
power = HDpow(2.0F, (double)(precision[0] - 1));
|
||||
orig_data[i][j].d[m][n].i =
|
||||
(int)(-((long long)HDrandom() % (long long)power) << offset[0]);
|
||||
(int)(-(((long long)HDrandom() % (long long)power) << offset[0]));
|
||||
power = HDpow(2.0F, (double)(precision[1] - 1));
|
||||
orig_data[i][j].d[m][n].c =
|
||||
(char)(((long long)HDrandom() % (long long)power) << offset[1]);
|
||||
|
Loading…
Reference in New Issue
Block a user