diff options
author | Sven van Haastregt <sven.vanhaastregt@arm.com> | 2023-07-19 09:48:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-19 09:48:59 +0100 |
commit | c3babfeebbc7eb09399331ca17bb89da2b77c777 (patch) | |
tree | c376eadd8921be69d9dd960d21ed03882f099324 | |
parent | 3c1f2814b87a7d54c17954c6937df3097f54d274 (diff) | |
download | OpenCL-CTS-c3babfeebbc7eb09399331ca17bb89da2b77c777.tar.gz |
conversions: fix undefined behaviour from shift by 64 (#1788)
Avoid a shift by 64 on a `uint64_t`. The value resulting from the
spurious shift was overwritten later, so just avoid the shift in that
case.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
-rw-r--r-- | test_conformance/conversions/basic_test_conversions.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/test_conformance/conversions/basic_test_conversions.cpp b/test_conformance/conversions/basic_test_conversions.cpp index 43fb449b..1020638a 100644 --- a/test_conformance/conversions/basic_test_conversions.cpp +++ b/test_conformance/conversions/basic_test_conversions.cpp @@ -538,7 +538,6 @@ int ConversionsTest::DoTest(Type outType, Type inType, SaturationMode sat, cl_ulong wall_start = mach_absolute_time(); #endif - uint64_t lastCase = 1ULL << (8 * gTypeSizes[inType]); cl_uint threads = GetThreadCount(); DataInitInfo info = { 0, 0, outType, inType, sat, round, threads }; @@ -601,7 +600,9 @@ int ConversionsTest::DoTest(Type outType, Type inType, SaturationMode sat, // Figure out how many elements are in a work block // we handle 64-bit types a bit differently. - if (8 * gTypeSizes[inType] > 32) lastCase = 0x100000000ULL; + uint64_t lastCase = (8 * gTypeSizes[inType] > 32) + ? 0x100000000ULL + : 1ULL << (8 * gTypeSizes[inType]); if (!gWimpyMode && gIsEmbedded) step = blockCount * EMBEDDED_REDUCTION_FACTOR; |