aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKostis Sagonas <[email protected]>2015-11-27 17:17:21 +0100
committerMagnus Lång <[email protected]>2015-11-27 18:18:38 +0100
commit720139f2d285a5746ba712efa236ad4938436e0f (patch)
treefefdce189f6953afb11bd22ecf05e730dc7e33a5 /lib
parent57b192d8ad6c319b20da48e55485799168f4d346 (diff)
downloadotp-720139f2d285a5746ba712efa236ad4938436e0f.tar.gz
otp-720139f2d285a5746ba712efa236ad4938436e0f.tar.bz2
otp-720139f2d285a5746ba712efa236ad4938436e0f.zip
Add a case testing the handling of guards involving binaries
The HiPE compiler was leaking exceptions out of guards involving binaries with `strange' arithmetic in them. Fixed by the set of changes in this pull request.
Diffstat (limited to 'lib')
-rw-r--r--lib/hipe/test/bs_SUITE_data/bs_add.erl10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/hipe/test/bs_SUITE_data/bs_add.erl b/lib/hipe/test/bs_SUITE_data/bs_add.erl
index af5a3b2f23..4b92e6b413 100644
--- a/lib/hipe/test/bs_SUITE_data/bs_add.erl
+++ b/lib/hipe/test/bs_SUITE_data/bs_add.erl
@@ -2,7 +2,7 @@
%%-------------------------------------------------------------------------
%% The guard in f/3 revealed a problem in the translation of the 'bs_add'
%% BEAM instruction to Icode. The fail label was not properly translated.
-%% Fixed 3/2/2011.
+%% Fixed 3/2/2011. Then in 2015 we found another issue: g/2. Also fixed.
%%-------------------------------------------------------------------------
-module(bs_add).
@@ -10,9 +10,17 @@
test() ->
42 = f(<<12345:16>>, 4711, <<42>>),
+ true = g(<<1:13>>, 3), %% was handled OK, but
+ false = g(<<>>, gurka), %% this one leaked badarith
ok.
f(Bin, A, B) when <<A:9, B:7/binary>> == Bin ->
gazonk;
f(Bin, _, _) when is_binary(Bin) ->
42.
+
+%% Complex way of testing (bit_size(Bin) + Len) rem 8 =:= 0
+g(Bin, Len) when is_binary(<<Bin/binary-unit:1, 123:Len>>) ->
+ true;
+g(_, _) ->
+ false.