代码如下:
-module(hipe_crash).
-export([f/6]).
f(A, B, C, D, E, L) ->
lists:foldl(fun (X, P) ->
AVar = case A of
0 -> 1 / D;
N -> N / (C - B)
end,
BVar = case E of
atom1 -> 1.0;
atom2 -> 0.8;
_ -> E
end,
CVar = case X of
atom1 -> 0.1 * AVar;
_ -> 1.0
end,
P * BVar * CVar
end, 1, L).
使用erlc
编译此代码时不会发生错误,编译就可以了。
但是当我用erlc +native
编译它时,编译器崩溃了,信息:
<HiPE (v 3.9.2)> EXITED with reason {function_clause,[{hipe_icode_fp,assert_assigned,[[{30,{icode_variable,40,fvar,[]}}]],[{file,[104,105,112,101,95,105,99,111,100,101,95,102,112,46,101,114,108]},{line,772}]},{hipe_icode_fp,bindings_are_assigned,1,[{file,[104,105,112,101,95,105,99,111,100,101,95,102,112,46,101,114,108]},{line,766}]},{hipe_icode_fp,filter_map,3,[{file,[104,105,112,101,95,105,99,111,100,101,95,102,112,46,101,114,108]},{line,753}]},{hipe_icode_fp,transform_block,2,[{file,[104,105,112,101,95,105,99,111,100,101,95,102,112,46,101,114,108]},{line,162}]},{hipe_icode_fp,cfg,1,[{file,[104,105,112,101,95,105,99,111,100,101,95,102,112,46,101,114,108]},{line,48}]},{hipe_main,icode_ssa_type,4,[{file,[104,105,112,101,95,109,97,105,110,46,101,114,108]},{line,273}]},{hipe_main,icode_ssa,4,[{file,[104,105,112,101,95,109,97,105,110,46,101,114,108]},{line,255}]},{hipe_main,compile_icode,5,[{file,[104,105,112,101,95,109,97,105,110,46,101,114,108]},{line,109}]}]} @hipe:829
hipe_crash.erl:none: internal error in native_compile;
crash reason: {{hipe,829,
{function_clause,
[{hipe_icode_fp,assert_assigned,
[[{30,{icode_variable,40,fvar,[]}}]],
[{file,"hipe_icode_fp.erl"},{line,772}]},
{hipe_icode_fp,bindings_are_assigned,1,
[{file,"hipe_icode_fp.erl"},{line,766}]},
{hipe_icode_fp,filter_map,3,
[{file,"hipe_icode_fp.erl"},{line,753}]},
{hipe_icode_fp,transform_block,2,
[{file,"hipe_icode_fp.erl"},{line,162}]},
{hipe_icode_fp,cfg,1,
[{file,"hipe_icode_fp.erl"},{line,48}]},
{hipe_main,icode_ssa_type,4,
[{file,"hipe_main.erl"},{line,273}]},
{hipe_main,icode_ssa,4,
[{file,"hipe_main.erl"},{line,255}]},
{hipe_main,compile_icode,5,
[{file,"hipe_main.erl"},{line,109}]}]}},
[{hipe,finalize_fun_sequential,3,
[{file,"hipe.erl"},{line,829}]},
{hipe,'-finalize_fun_concurrent/3-fun-3-',4,
[{file,"hipe.erl"},{line,795}]}]}
我在http://erlang.2086793.n4.nabble.com/internal-error-in-native-compile-td2298937.html中找到了这段代码。但我无法获得有关此代码崩溃编译器的原因的更多信息。
答案 0 :(得分:0)
BEAM浮点运算之一的优化是对浮点运算进行分组
如果某些中间操作失败,BEAM将发出badarith信号。它依赖于头饰
我认为这是异常处理程序的错误。您可以使用no_inline_fp
HiPE编译器选项
禁用所有浮点优化的费用。