Skip to content

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

@RobinMorisset

Description

@RobinMorisset

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.

Metadata

Metadata

Assignees

Labels

bugIssue is reported as a bugstalledwaiting for input by the Erlang/OTP teamteam: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