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 a guard #7370

Closed
RobinMorisset opened this issue Jun 7, 2023 · 0 comments · Fixed by #7378
Closed

[erlc] miscompilation of a guard #7370

RobinMorisset opened this issue Jun 7, 2023 · 0 comments · Fixed by #7378
Assignees
Labels
bug Issue is reported as a bug team:VM Assigned to OTP team VM

Comments

@RobinMorisset
Copy link
Contributor

RobinMorisset commented Jun 7, 2023

Describe the bug
Running the following code:

f(_V0) when (not (not is_float(_V0))) =/= ((ok and ok) or true) ->
    ok.

wrapper0() ->
    io:write(catch f(ok)).

with the following commands:

erlc -W0 ~/minimized/test812871.erl
erl -pa . -noshell -s test812871 wrapper0 -s init stop

results in ok being printed.

Expected behavior
I would expect to see the guard fail because of an exception being thrown by ok and ok.

Affected versions

Additional context
Adding +no_bool_opt to erlc makes this bug disappear: the output becomes

{'EXIT',{function_clause,[{test812871,f,[ok],[{file,[47,104,111,109,101,47,114,109,111,114,105,115,115,101,116,47,109,105,110,105,109,105,122,101,100,47,116,101,115,116,56,49,50,56,55,49,46,101,114,108]},{line,7}]},{test812871,wrapper0,0,[{file,[47,104,111,109,101,47,114,109,111,114,105,115,115,101,116,47,109,105,110,105,109,105,122,101,100,47,116,101,115,116,56,49,50,56,55,49,46,101,114,108]},{line,11}]},{init,start_em,1,[]},{init,do_boot,3,[]}]}}

Which is what I expect to see even with the bool_opt optimisation pass.

@RobinMorisset RobinMorisset added the bug Issue is reported as a bug label Jun 7, 2023
@bjorng bjorng self-assigned this Jun 7, 2023
@bjorng bjorng added the team:VM Assigned to OTP team VM label Jun 7, 2023
bjorng added a commit to bjorng/otp that referenced this issue Jun 8, 2023
@bjorng bjorng linked a pull request Jun 8, 2023 that will close this issue
@bjorng bjorng linked a pull request Jun 8, 2023 that will close this issue
bjorng added a commit that referenced this issue Jun 9, 2023
…compilation/GH-7370/OTP-18634

Fix miscompilation of guard with `or`
@bjorng bjorng closed this as completed Jun 9, 2023
bjorng pushed a commit that referenced this issue Jun 29, 2023
…-18634' into maint-26

* bjorn/compiler/beam_ssa_bool-miscompilation/GH-7370/OTP-18634:
  Fix miscompilation of guard with `or`
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

Successfully merging a pull request may close this issue.

2 participants