[erlang-bugs] Bug in binary append?

Oleg Avdeev oavdeev@REDACTED
Fri Dec 7 23:29:33 CET 2007


Hello,

Seems that there's a bug in R12, while compiling

%%
% get_tail(Bin, Tail, Len)
% Return last Len bytes of <<Bin, Tail>>
get_tail(Bin, Tail, Len) when size(Bin) + size(Tail) < Len->
    <<Tail/binary, Bin/binary>>
    ;

get_tail(Bin, Tail, Len) when size(Bin) < Len ->
    L = size(Tail) - (Len - size(Bin)),
    <<_:L/binary, Tail1/binary>> = Tail,
    <<Tail1/binary, Bin/binary>>;

get_tail(Bin, Tail, Len) ->
        S = size(Bin) - Len,
        case Bin of
            <<_:S/binary, NewTail:Len/binary>> ->
                NewTail;
            _ ->
                <<Tail/binary, Bin/binary>>
        end.

I get an error

$ erlc -W r12_test.erl
r12_test: function get_tail/3+29:
  Internal consistency check failed - please report this bug.
  Instruction: {bs_append,{f,0},{x,2},0,2,8,{x,1},{field_flags,[]},{x,2}}
  Error:       {match_context,{x,1}}:

In R11 this code compiles ok.

Best Regards,
Oleg.



More information about the erlang-bugs mailing list