Skip to content

Commit 80db053

Browse files
committed
Fixing build errors under legacy libc++.
1 parent 6a86ef5 commit 80db053

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

include/simdjson/generic/numberparsing.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,9 @@ simdjson_really_inline bool compute_float_64(int64_t power, uint64_t i, bool neg
292292
// one digit.
293293
static bool parse_float_fallback(const uint8_t *ptr, double *outDouble) {
294294
*outDouble = simdjson::internal::from_chars((const char *)ptr);
295-
// We do not accept infinite values.
296-
if (!std::isfinite(*outDouble)) {
295+
// We do not accept infinite values. Yes, there is a std::isfinite function, but
296+
// it appears to be broken in legacy libc++.
297+
if ((*outDouble > 0x1.fffffffffffffp+1023) || (*outDouble < -0x1.fffffffffffffp+1023)) {
297298
return false;
298299
}
299300
return true;

src/to_chars.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -914,8 +914,13 @@ format. Returns an iterator pointing past-the-end of the decimal representation.
914914
*/
915915
char *to_chars(char *first, const char *last, double value) {
916916
static_cast<void>(last); // maybe unused - fix warning
917-
// Use signbit(value) instead of (value < 0) since signbit works for -0.
918-
if (std::signbit(value)) {
917+
// It would be better to use signbit(value) instead of (value < 0) since signbit works for -0.
918+
//if(std::signbit(value)) {
919+
// value = -value;
920+
// *first++ = '-';
921+
//}
922+
// However, under older libc++, std::signbit causes build errors, so falling back:
923+
if((value < 0) || (value == -0)){
919924
value = -value;
920925
*first++ = '-';
921926
}

0 commit comments

Comments
 (0)