From 1f8ead914a6ded848bdb2ee92e7b842b5bdc03cf Mon Sep 17 00:00:00 2001 From: Vikram Date: Thu, 9 Nov 2023 05:42:06 -0500 Subject: [PATCH] SWDEV-423946 - Make hash string to int conversion platform independent The "long" type size seems to be platform dependent, causing hash value overflow on implementations where "long" is 4 bytes. This addresses the scenario. Change-Id: I4e3c0df457e35b139dcc496d832210ba2cb849ba --- rocclr/device/devhcprintf.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rocclr/device/devhcprintf.cpp b/rocclr/device/devhcprintf.cpp index 56c1f04e32..18ae4f79da 100644 --- a/rocclr/device/devhcprintf.cpp +++ b/rocclr/device/devhcprintf.cpp @@ -260,7 +260,9 @@ bool populateFormatStringHashMap( for (auto it : printfInfo) { auto Delim = it.fmtString_.find_first_of(','); auto HashStr = it.fmtString_.substr(0, Delim); - auto HashVal = strtoul(HashStr.c_str(), NULL, 16); + + static_assert(sizeof(long long) == sizeof(uint64_t), "unexpected long long type width"); + auto HashVal = std::strtoull(HashStr.c_str(), NULL, 16); if (strMap.find(HashVal) != strMap.end()) { LogError("Hash value collision detected, printf buffer ill formed"); return false;