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] bad_typed_register/bad_arg_type on bnot with finite/infinite bounds #7468

Closed
RobinMorisset opened this issue Jul 4, 2023 · 2 comments · Fixed by #7562
Closed

[erlc] bad_typed_register/bad_arg_type on bnot with finite/infinite bounds #7468

RobinMorisset opened this issue Jul 4, 2023 · 2 comments · Fixed by #7562
Assignees
Labels
bug Issue is reported as a bug stalled waiting for input by the Erlang/OTP team team:VM Assigned to OTP team VM

Comments

@RobinMorisset
Copy link
Contributor

Describe the bug
Running erlc on one of the following testcases:

f1() ->
    (bnot erlang:round(abs(bit_size(float_to_binary(float(18446744073709551615))) - (group_leader(ok, ok) orelse 2147483647)))) + ok.

or

f2(_V1) ->
    (bnot round(((_V1 xor false) andalso 2147483647) + 2147483647)) bsr ok.

results in an error like the following:

test178921:1: function f1/0+22:
  Internal consistency check failed - please report this bug.
  Instruction: {gc_bif,'+',
                       {f,0},
                       1,
                       [{tr,{x,0},{t_integer,{4294966877,'+inf'}}},{atom,ok}],
                       {x,0}}
  Error:       {bad_typed_register,{t_integer,{2147483438,2147483438}},
                                   {t_integer,{4294966877,'+inf'}}}:

Probably related: running erlc on

f3() ->
    << 0 || _V0 <- "Tl5briN", _ <- bnot erlang:round((_V0 + trunc(_V0)))>>.

results in

test10044:1: function '-f3/0-lbc$^0/2-0-'/2+12:
  Internal consistency check failed - please report this bug.
  Instruction: {call_only,2,{f,14}}
  Error:       {bad_arg_type,{x,0},
                             {t_integer,{-457,-107}},
                             {t_integer,{'-inf',-213}}}:

Affected versions
master
I could not reproduce this bug with an old version of OTP 25 I had lying around, so the bug must have been introduced in the past year.

Additional context
I suspect that this is related to #7254 (@jhogberg) which was a fix to the very similar #7251.

@RobinMorisset RobinMorisset added the bug Issue is reported as a bug label Jul 4, 2023
@jhogberg jhogberg added team:VM Assigned to OTP team VM waiting waiting for changes/input from author stalled waiting for input by the Erlang/OTP team and removed waiting waiting for changes/input from author labels Jul 4, 2023
@jhogberg
Copy link
Contributor

jhogberg commented Jul 4, 2023

Thanks for your report! Just as a heads-up, we're a bit short-handed over the summer vacation period, so it'll take a while before I can get around to this.

@RobinMorisset
Copy link
Contributor Author

There is no hurry, thank you for the heads-up.

@bjorng bjorng self-assigned this Jul 31, 2023
bjorng added a commit to bjorng/otp that referenced this issue Aug 13, 2023
@bjorng bjorng linked a pull request Aug 14, 2023 that will close this issue
bjorng added a commit to bjorng/otp that referenced this issue Aug 15, 2023
…into maint

* bjorn/compiler/fix-bnot-again/erlangGH-7468/OTP-18719:
  Fix unsafe range calculation for the bnot operator
@bjorng bjorng closed this as completed in ad63af9 Aug 15, 2023
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 stalled waiting for input by the Erlang/OTP team team:VM Assigned to OTP team VM
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants