Skip to content

Commit

Permalink
deps: workaround stod() limitations on SmartOS
Browse files Browse the repository at this point in the history
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: #37330
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
cjihrig authored and targos committed Feb 24, 2021
1 parent 70f928c commit 19d9752
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -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 #####

Expand Down
10 changes: 10 additions & 0 deletions deps/v8/src/torque/torque-parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1833,7 +1833,17 @@ base::Optional<ParseResult> 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<double>(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();
}
Expand Down

0 comments on commit 19d9752

Please sign in to comment.