diff options
author | John Högberg <[email protected]> | 2019-06-10 17:21:52 +0200 |
---|---|---|
committer | John Högberg <[email protected]> | 2019-06-10 17:26:55 +0200 |
commit | a726c015867beffe15cc20ee22e32778678e8fdf (patch) | |
tree | fc51318cfa6b66815108a31e62d2e495e0093154 /lib/compiler/test | |
parent | abbe8d424676a473bcebdf3b97996ac7a5a70f16 (diff) | |
download | otp-a726c015867beffe15cc20ee22e32778678e8fdf.tar.gz otp-a726c015867beffe15cc20ee22e32778678e8fdf.tar.bz2 otp-a726c015867beffe15cc20ee22e32778678e8fdf.zip |
beam_ssa_type: Fix incorrect bitstring unit determination
The compiler would treat the "Unit" of bs_init instructions as
the unit of the result instead of the required unit of the input,
causing is_binary checks to be wrongly optimized away.
Diffstat (limited to 'lib/compiler/test')
-rw-r--r-- | lib/compiler/test/beam_type_SUITE.erl | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/compiler/test/beam_type_SUITE.erl b/lib/compiler/test/beam_type_SUITE.erl index 2297c2e0f5..076a604aa4 100644 --- a/lib/compiler/test/beam_type_SUITE.erl +++ b/lib/compiler/test/beam_type_SUITE.erl @@ -24,7 +24,7 @@ integers/1,numbers/1,coverage/1,booleans/1,setelement/1, cons/1,tuple/1,record_float/1,binary_float/1,float_compare/1, arity_checks/1,elixir_binaries/1,find_best/1, - test_size/1,cover_lists_functions/1,list_append/1]). + test_size/1,cover_lists_functions/1,list_append/1,bad_binary_unit/1]). suite() -> [{ct_hooks,[ts_install_cth]}]. @@ -48,7 +48,8 @@ groups() -> find_best, test_size, cover_lists_functions, - list_append + list_append, + bad_binary_unit ]}]. init_per_suite(Config) -> @@ -508,5 +509,14 @@ list_append(_Config) -> hello = id([]) ++ id(hello), ok. +%% OTP-15872: The compiler would treat the "Unit" of bs_init instructions as +%% the unit of the result instead of the required unit of the input, causing +%% is_binary checks to be wrongly optimized away. +bad_binary_unit(_Config) -> + Bin = id(<<1,2,3>>), + Bitstring = <<Bin/binary,1:1>>, + false = is_binary(Bitstring), + ok. + id(I) -> I. |