From 3fbbee6d3497d70ec7b050b2ecb4b60ca50170e7 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 428ee9e80490fb..413d8452b30167 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(); }