summaryrefslogtreecommitdiff
path: root/erl-build-tool-vars.sh
diff options
context:
space:
mode:
authorFrej Drejhammar <frej.drejhammar@gmail.com>2023-05-04 14:57:56 +0200
committerFrej Drejhammar <frej.drejhammar@gmail.com>2023-05-04 15:13:05 +0200
commit5277d99c337d85766dd8c087413ae7598390e743 (patch)
tree6bf85045575e9063018fe4d6432f63d3e79cd151 /erl-build-tool-vars.sh
parentc9919949e055dea8f86d50ea7fef70eefd835e00 (diff)
downloaderlang-5277d99c337d85766dd8c087413ae7598390e743.tar.gz
compiler: Avoid invalid code for bs_create_bin with initial literal
This change stops the compiler from generating invalid code when bs_create_bin is given a literal <<>> as its first fragment. As the type analyzer considers a literal <<>> an appendable bitstring, code sequences such as: _6 = bs_create_bin `append`, `[8,{segment,1}]`, `<<>>`, `all` ... _14 = bs_create_bin `append`, `[8,{segment,1}]`, _6, `all` would be rewritten to: _6 = bs_create_bin `private_append`, `[8,{segment,1}]`, `<<>>`, `all` ... _14 = bs_create_bin `private_append`, `[8,{segment,1}]`, _6, `all` which is not legal, as private_append on a literal will crash the runtime system. By inserting a bs_init_writable in front of bs_create_bin instructions with a literal <<>> as the first fragment, and then using the freshly created writable binary instead of the literal, the code sequence becomes valid: _1 = bs_init_writable `256` _6 = bs_create_bin `private_append`, `[8,{segment,1}]`, _1, `all` ... _14 = bs_create_bin `private_append`, `[8,{segment,1}]`, _6, `all`
Diffstat (limited to 'erl-build-tool-vars.sh')
0 files changed, 0 insertions, 0 deletions