Skip to content
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

[erlc] miscompilation of pattern that can return either 0.0 or -0.0 #7168

Closed
RobinMorisset opened this issue Apr 25, 2023 · 2 comments
Closed
Assignees
Labels
bug Issue is reported as a bug team:VM Assigned to OTP team VM
Milestone

Comments

@RobinMorisset
Copy link
Contributor

Describe the bug
The following code:

f(_V0, _V0) ->
    -0.0;
f(_, _) ->
    0.0.

wrapper() ->
    io:write(f(ok, [])).

prints -0.0 whereas I would expect 0.0

Affected versions

Additional context
Compiling the code with +no_fold +no_ssa_opt makes it print 0.0 as expected.

@RobinMorisset RobinMorisset added the bug Issue is reported as a bug label Apr 25, 2023
@bjorng bjorng added the team:VM Assigned to OTP team VM label Apr 26, 2023
@jhogberg jhogberg added this to the OTP-27.0 milestone May 5, 2023
@jhogberg
Copy link
Contributor

jhogberg commented May 5, 2023

We're aiming to fix this in OTP 27 by making matching and =:= distinguish between +0.0 and -0.0:

https://erlangforums.com/t/in-erlang-otp-27-0-0-will-no-longer-be-exactly-equal-to-0-0/2586

@jhogberg
Copy link
Contributor

Fixed in OTP 27, thanks for your report :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is reported as a bug team:VM Assigned to OTP team VM
Projects
None yet
Development

No branches or pull requests

3 participants