Skip to content

[erlc] miscompilation of a guard #7252

@RobinMorisset

Description

@RobinMorisset

Describe the bug
Running the following erlang code:

f(_, _V1) when ((ok == _V1) and (ok =/= trunc(ok))) or (ok < _V1) ->
    a;
f(_V0, _) ->
    _V0.

wrapper0() ->
    io:write(f(b, [])).

with the following two commands:

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

results in the output a.
Passing +no_bool_opt to erlc makes it output b instead.

Expected behavior
trunc(ok) is always going to throw an exception, and so the whole guard should fail.
So the behavior with +no_bool_opt is I believe the right one, and should also occur without that option.

Affected versions

Metadata

Metadata

Assignees

Labels

bugIssue is reported as a bugteam:VMAssigned to OTP team VM

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions