[erlang-questions] hipe problems with R14B?

Kostis Sagonas <>
Fri Oct 15 15:14:09 CEST 2010


Dan Kelley wrote:
> I can't, but this minimal reproducer shows the problem:
> 
> -----
> -module(example).
> -export([bar/1]).
> 
> bar (Baz) ->
>     binary_part(Baz, 0, 1).

Thanks!  This is more than sufficient.  In fact, this is _exactly_ the 
information I would like to see.

> That compiles without +native, but throws the same error with +native.
> 
> While making up the reproducer, I tried this with the 2-arity version of
> binary_part (i.e., binary_part(Baz, {0,1}), and that seemed to work fine.

Well, it's not surprising.  This is the first time that a BIF with three 
arguments was ever introduced to BEAM and the BEAM->ICode translation 
was never notified about it.  It currently has cases for:

%%--- bif0 ---
trans_fun([{bif,BifName,nofail,[],Reg}|Instructions], Env) ->
   BifInst = trans_bif0(BifName,Reg),
   ....
%%--- bif1 ---
trans_fun([{bif,BifName,{f,Lbl},[_] = Args,Reg}|Instructions], Env) ->
   {BifInsts,Env1} = trans_bif(1,BifName,Lbl,Args,Reg,Env),
   ...
%%--- bif2 ---
trans_fun([{bif,BifName,{f,Lbl},[_,_] = Args,Reg}|Instructions], Env) ->
   {BifInsts,Env1} = trans_bif(2,BifName,Lbl,Args,Reg,Env),
   ...

and there is no case for BIFs with more than two arguments.  I will look 
into this.


But, out of curiosity, is there really a need to have both binary_part/2 
and binary_part/3 as BIFs in the language?


Kostis


PS. I also noticed that the manual contains a typo:

         2> binary_part(Bin,{byte_size(Bin), -5)).

     The first ) should be }


More information about the erlang-questions mailing list