[erlang-patches] binary matching optimization error
Christian von Roques
Thu Aug 21 22:08:56 CEST 2008
Christian von Roques <> writes:
> Using R12B-3 I recently wrote code similar to the following:
> %% foo(<<1,2>>, 2) should evaluate to <<1,2>>, but evaluates to <<2>>
> %% when compiled without no_bsm_opt
> foo(Bin, 0) ->
> foo(Bin, 42);
> foo(<<_A, Rest/bitstring>>, 1) ->
> foo(Rest, 43);
> foo(Bin, _I) ->
Unfortunately this is not the whole problem.
bar(<<1,2>>, 3) should evaluate to <<1,2>> as well:
bar(Bin, 0) ->
bar(<<_A, Rest/bitstring>>, 1) ->
bar(<<>>, 2) ->
bar(Bin, _I) ->
Here the problem is with bs_restore2.
I've amended my patch, but still hope for a more complete solution
from the Erlang team e.g. by placing the bs_save2 only in those
control flow paths where they are needed and not modifying the
original match context where it is still needed.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
More information about the erlang-patches