From b2fd00398c9923056dd0c312e89f1ad3fdb01526 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Mon, 8 Mar 2021 21:07:48 -0500 Subject: [PATCH] deps: V8: cherry-pick 1648e050cade MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Original commit message: torque: workaround stod() limitations on Solaris std::stod() on Solaris does not currently handle hex strings. This commit provides a workaround based on strtol() until proper stod() support is available. This was encountered while updating Node.js to V8 8.8. For more details see the following comment: https://github.com/nodejs/node/pull/36139#issuecomment-740131942 Change-Id: I16ed80a817f6d9105e7153b10824b1fee8520432 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2692746 Reviewed-by: Michael Stanton Commit-Queue: Michael Stanton Cr-Commit-Position: refs/heads/master@{#73255} Refs: https://github.com/v8/v8/commit/1648e050cade0e0803714a488ab0c8817d9eaf5c PR-URL: https://github.com/nodejs/node/pull/37664 Reviewed-By: Michaƫl Zasso Reviewed-By: Rich Trott --- deps/v8/src/torque/torque-parser.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/deps/v8/src/torque/torque-parser.cc b/deps/v8/src/torque/torque-parser.cc index 14fdd97b18307c..251519a9e65f04 100644 --- a/deps/v8/src/torque/torque-parser.cc +++ b/deps/v8/src/torque/torque-parser.cc @@ -1799,7 +1799,18 @@ 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") == std::string::npos && + number.find("0X") == std::string::npos) { + value = std::stod(number); + } else { + value = static_cast(strtol(number.c_str(), nullptr, 0)); + } +#else value = std::stod(number); +#endif // !defined(V8_OS_SOLARIS) } catch (const std::out_of_range&) { Error("double literal out-of-range").Throw(); }