erlang/otp

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

RobinMorisset opened this issue · 2 comments

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.

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

Fixed in OTP 27, thanks for your report :)