Fix -Wimplicit-const-int-float-conversion warnings
Compare against 0x1p63 instead of INT64_MAX. Converting INT64_MAX to double rounds it up to INT64_MAX+1. It made code like `if (d <= INT64_MAX) v = (int64_t)d;` behave subtly wrong when `d >= 0x1p63` because then `v = (int64_t)d` wraps around to a negative value.
This commit is contained in:
parent
62f67892ad
commit
67585d0421
1 changed files with 2 additions and 2 deletions
|
@ -10738,7 +10738,7 @@ static int JS_ToInt64SatFree(JSContext *ctx, int64_t *pres, JSValue val)
|
||||||
} else {
|
} else {
|
||||||
if (d < INT64_MIN)
|
if (d < INT64_MIN)
|
||||||
*pres = INT64_MIN;
|
*pres = INT64_MIN;
|
||||||
else if (d > INT64_MAX)
|
else if (d >= 0x1p63)
|
||||||
*pres = INT64_MAX;
|
*pres = INT64_MAX;
|
||||||
else
|
else
|
||||||
*pres = (int64_t)d;
|
*pres = (int64_t)d;
|
||||||
|
@ -53844,7 +53844,7 @@ static JSValue js_atomics_wait(JSContext *ctx,
|
||||||
}
|
}
|
||||||
if (JS_ToFloat64(ctx, &d, argv[3]))
|
if (JS_ToFloat64(ctx, &d, argv[3]))
|
||||||
return JS_EXCEPTION;
|
return JS_EXCEPTION;
|
||||||
if (isnan(d) || d > INT64_MAX)
|
if (isnan(d) || d >= 0x1p63)
|
||||||
timeout = INT64_MAX;
|
timeout = INT64_MAX;
|
||||||
else if (d < 0)
|
else if (d < 0)
|
||||||
timeout = 0;
|
timeout = 0;
|
||||||
|
|
Loading…
Reference in a new issue