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 <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
cjihrig authored and targos committed Feb 25, 2021
1 parent 5851c85 commit a49a4e4
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 @@ -1834,7 +1834,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 a49a4e4

Please sign in to comment.