Skip to content

Commit

Permalink
deps: V8: cherry-pick 1648e050cade
Browse files Browse the repository at this point in the history
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:

    nodejs#36139 (comment)

    Change-Id: I16ed80a817f6d9105e7153b10824b1fee8520432
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2692746
    Reviewed-by: Michael Stanton <mvstanton@chromium.org>
    Commit-Queue: Michael Stanton <mvstanton@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#73255}

Refs: v8/v8@1648e05
PR-URL: nodejs#37664
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
cjihrig committed Mar 11, 2021
1 parent 25985d6 commit 8a6d7a0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions deps/v8/src/torque/torque-parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1836,14 +1836,15 @@ base::Optional<ParseResult> MakeNumberLiteralExpression(
#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<double>(strtol(number.c_str(), nullptr, 0));
} else {
if (number.find("0x") == std::string::npos &&
number.find("0X") == std::string::npos) {
value = std::stod(number);
} else {
value = static_cast<double>(strtol(number.c_str(), nullptr, 0));
}
#else
value = std::stod(number);
#endif // !defined(V8_OS_SOLARIS)
#endif // !defined(V8_OS_SOLARIS)
} catch (const std::out_of_range&) {
Error("double literal out-of-range").Throw();
}
Expand Down

0 comments on commit 8a6d7a0

Please sign in to comment.