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: nodejs/node#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 nodejs-ci committed Feb 26, 2021
1 parent bcd9a1a commit 3008161
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 3008161

Please sign in to comment.