Skip to content

Commit 1648e05

Browse files
cjihrigCommit Bot
authored andcommitted
torque: workaround stod() limitations on Solaris
std::stod() on Solaris does not currently handle hex strings. This commit provides a workaround based on strtol() until proper stod() support is available. This was encountered while updating Node.js to V8 8.8. For more details see the following comment: nodejs/node#36139 (comment) Change-Id: I16ed80a817f6d9105e7153b10824b1fee8520432 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2692746 Reviewed-by: Michael Stanton <[email protected]> Commit-Queue: Michael Stanton <[email protected]> Cr-Commit-Position: refs/heads/master@{#73255}
1 parent 7585aaf commit 1648e05

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/torque/torque-parser.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1834,7 +1834,18 @@ base::Optional<ParseResult> MakeNumberLiteralExpression(
18341834
// Meanwhile, we type it as constexpr float64 when out of int32 range.
18351835
double value = 0;
18361836
try {
1837+
#if defined(V8_OS_SOLARIS)
1838+
// stod() on Solaris does not currently support hex strings. Use strtol()
1839+
// specifically for hex literals until stod() support is available.
1840+
if (number.find("0x") == std::string::npos &&
1841+
number.find("0X") == std::string::npos) {
1842+
value = std::stod(number);
1843+
} else {
1844+
value = static_cast<double>(strtol(number.c_str(), nullptr, 0));
1845+
}
1846+
#else
18371847
value = std::stod(number);
1848+
#endif // !defined(V8_OS_SOLARIS)
18381849
} catch (const std::out_of_range&) {
18391850
Error("double literal out-of-range").Throw();
18401851
}

0 commit comments

Comments
 (0)