aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/v3_kernel.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2018-08-07 12:52:33 +0200
committerBjörn Gustavsson <[email protected]>2018-08-08 13:57:24 +0200
commit2e40d8d1c51ad1c3d3750490ecac6b290233f085 (patch)
tree8807a55b35ad9f3a8bacd03e2f95ece8fedd75c6 /lib/compiler/src/v3_kernel.erl
parentce0ab49ca59dc56cb4774abc1f635b7ff9cf97df (diff)
downloadotp-2e40d8d1c51ad1c3d3750490ecac6b290233f085.tar.gz
otp-2e40d8d1c51ad1c3d3750490ecac6b290233f085.tar.bz2
otp-2e40d8d1c51ad1c3d3750490ecac6b290233f085.zip
Fix bug in binary matching
The compiler generates incorrect code for the following example: decode_binary(_, <<Length, Data/binary>>) -> case {Length, Data} of {0, _} -> %% When converting the match context back to a binary, %% Data will be set to the entire original binary, %% that is, to <<0>> instead of <<>>. {{0, 0, 0}, Data}; {4, <<Y:16/little, M, D, Rest/binary>>} -> {{Y, M, D}, Rest} end. The problem is the delayed sub binary creation optimization, which is not safe to do in this case. This commit introduces a heuristic that will disable the delayed sub binary creation optimization for this example. Unfortunately, the heuristic may turn off the optimization when it would actually be safe. In the OTP codebase, the optimization is turned off in two instances, once in string.erl and once in dets_v9.erl. https://bugs.erlang.org/browse/ERL-689
Diffstat (limited to 'lib/compiler/src/v3_kernel.erl')
0 files changed, 0 insertions, 0 deletions