-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error in max_double implementation #57119
Comments
Here is a stand-alone test case: struct IV
a::Float64
b::Float64
end
width(iv::IV) = (w=iv.b-iv.a; max(zero(w),w))
Base.mod(x,iv::IV) = mod(x-iv.a, width(iv)) + iv.a
f(x) = (iv=IV(0.0,1.0); mod(x,iv))
f(0.0) The call to |
Any reference for when this last worked? It'd help for a bisect. |
Sorry, no – 1.11 works for me. |
on my machine this bisects to
|
Look at these two functions from float max_float(float x, float y) JL_NOTSAFEPOINT
{
float diff = x - y;
float argmin = signbit(diff) ? y : x;
int is_nan = isnan(x) || isnan(y);
return is_nan ? diff : argmin;
}
double max_double(double x, double y) JL_NOTSAFEPOINT
{
double diff = x - y;
double argmin = signbit(diff) ? x : y;
int is_nan = isnan(x) || isnan(y);
return is_nan ? diff : argmin;
} Do you spot the difference? Only one of them is correct... |
Spoiler alert: the variable should be called |
This function didn't exist in 1.10/1.11 so no backports needed |
Ah okay, I didn't realize #56371 was new. All new intrinsics added should have a test added to exercise them in test/intrinsics.jl |
@gbaraldi This is still a regression in 1.12... |
Too many tags 😕 yeh |
I see this strange behaviour in Julia 1.12-dev (todays nightly build), first reported at MakieOrg/Makie.jl#4729:
The correct result is
0.0
, and this works fine in Julia 1.11, and also whenmod
is called directly instead of in a function (mod(0.0, 0.0..1.0)
).I believe this is a bug in Julia's constant propagation mechanism. I have posted more details in the
Makie.jl
issue.I see that Julia determines already at compile time that the call to
mod
will returnNaN
:IntervalSets'
mod
function isand its
width
function isI find that removing the line calling
max
avoids the problem. It seems to me that this line somehow confuses Julia into assuming that the second argument tomod
is 0.The text was updated successfully, but these errors were encountered: