From 2b7fa3acaaf12b36a94908c25ca8c1ae246d52fc Mon Sep 17 00:00:00 2001 From: cjihrig Date: Mon, 7 Dec 2020 23:46:58 -0500 Subject: [PATCH] deps: workaround stod() limitations on SmartOS std::stod() on SmartOS does not currently handle hex strings. This commit provides a workaround based on strtol() until proper stod() support is available. PR-URL: https://github.com/nodejs/node/pull/37330 Reviewed-By: Jiawen Geng Reviewed-By: Colin Ihrig Reviewed-By: Rich Trott --- common.gypi | 2 +- deps/v8/src/torque/torque-parser.cc | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/common.gypi b/common.gypi index 79a22ac0faca37..5e6383ab3cc44d 100644 --- a/common.gypi +++ b/common.gypi @@ -36,7 +36,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.7', + 'v8_embedder_string': '-node.8', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/src/torque/torque-parser.cc b/deps/v8/src/torque/torque-parser.cc index 9008ed49b024c8..1d7dbe35290fa5 100644 --- a/deps/v8/src/torque/torque-parser.cc +++ b/deps/v8/src/torque/torque-parser.cc @@ -1834,7 +1834,17 @@ base::Optional MakeNumberLiteralExpression( // Meanwhile, we type it as constexpr float64 when out of int32 range. double value = 0; try { +#if defined(V8_OS_SOLARIS) + // stod() on Solaris does not currently support hex strings. Use strtol() + // specifically for hex literals until stod() support is available. + if (number.find("0x") || number.find("0X")) { + value = static_cast(strtol(number.c_str(), nullptr, 0)); + } else { + value = std::stod(number); + } +#else value = std::stod(number); +#endif // !defined(V8_OS_SOLARIS) } catch (const std::out_of_range&) { Error("double literal out-of-range").Throw(); }