Skip to content

Commit 19d9752

Browse files
cjihrigtargos
authored andcommitted
deps: workaround stod() limitations on SmartOS
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]>
1 parent 70f928c commit 19d9752

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
# Reset this number to 0 on major V8 upgrades.
3838
# Increment by one for each non-official patch applied to deps/v8.
39-
'v8_embedder_string': '-node.7',
39+
'v8_embedder_string': '-node.8',
4040

4141
##### V8 defaults for Node.js #####
4242

deps/v8/src/torque/torque-parser.cc

+10
Original file line numberDiff line numberDiff line change
@@ -1833,7 +1833,17 @@ base::Optional<ParseResult> MakeNumberLiteralExpression(
18331833
// Meanwhile, we type it as constexpr float64 when out of int32 range.
18341834
double value = 0;
18351835
try {
1836+
#if defined(V8_OS_SOLARIS)
1837+
// stod() on Solaris does not currently support hex strings. Use strtol()
1838+
// specifically for hex literals until stod() support is available.
1839+
if (number.find("0x") || number.find("0X")) {
1840+
value = static_cast<double>(strtol(number.c_str(), nullptr, 0));
1841+
} else {
1842+
value = std::stod(number);
1843+
}
1844+
#else
18361845
value = std::stod(number);
1846+
#endif // !defined(V8_OS_SOLARIS)
18371847
} catch (const std::out_of_range&) {
18381848
Error("double literal out-of-range").Throw();
18391849
}

0 commit comments

Comments
 (0)