Niall Burton
Niall Burton

Reputation: 21

VarI4FromStr broken at lowest long value on ARM64?

The following code is fine on regular x64 Windows.

const LCID LOCALE_EN_US = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT);
long val;
BSTR str = SysAllocString(L"-2147483648"));
if (VarI4FromStr(str, LOCALE_EN_US,0,&val) == S_OK)
{
  //False on arm64, true on regular x64
}
SysFreeString(str);

However, on arm64 VarI4FromStr returns DISP_E_OVERFLOW. This seems very strange, especially since the following:

short val;
BSTR str = SysAllocString(L"-32768"));
if (VarI2FromStr(str, LOCALE_EN_US,0,&val) == S_OK)
{
  //True on arm64
}
SysFreeString(str);

which seems to be doing the exact same thing for 2 bytes, works fine. It also works fine with positive 2147483647.

Upvotes: 0

Views: 75

Answers (0)

Related Questions