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.
  • Loading branch information
cjihrig authored and targos committed Feb 11, 2021
1 parent 0ddd839 commit 73f8c2d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion common.gypi
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.8',
'v8_embedder_string': '-node.9',

##### V8 defaults for Node.js #####

Expand Down
10 changes: 10 additions & 0 deletions deps/v8/src/torque/torque-parser.cc
Expand Up @@ -1830,7 +1830,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 73f8c2d

Please sign in to comment.