Compiler bug in Erlang R7B-1 (bit syntax)

Pascal Brisset Pascal.Brisset@REDACTED
Sat Dec 16 12:06:20 CET 2000


A colleague of mine recently noticed the following problem with Erlang
OTP R7B-1, compiler version 3.0.1.1.

The following code:

| -module(foo).
| bar() -> case ok of ok -> X=0 end, <<X>>.

crashes the compiler with this error:

| /home/pb/foo.erl:none: internal error in v3_codegen;
| crash reason: {{case_clause,{'EXIT',{function_clause,
| 					  [{v3_codegen,fetch_reg,['X',[]]},
| 					   {v3_codegen,'-saves/3-fun-0-',3},
| 					   {lists,map,2},
| 					   {v3_codegen,adjust_stack,4},
| 					   {v3_codegen,match_cg,6},
| 					   {v3_codegen,'-cg_list/5-fun-0-',3},
| 					   {v3_codegen,flatmapfoldl,3},
| 					   {v3_codegen,cg_list,5}|
| 					   more]}}},
| 		 [{compile,'-select_passes/2-fun-2-',2},
| 		  {compile,'-internal_comp/4-fun-1-',2},
| 		  {compile,fold_comp,3},
| 		  {compile,internal_comp,4},
| 		  {compile,internal,3}]}

I believe the problem is in v3_core.erl and can be corrected as follows:

--- v3_core.erl.dist    Sat Dec 16 11:39:06 2000
+++ v3_core.erl Sat Dec 16 11:47:05 2000
@@ -705,6 +705,8 @@
 
 lit_vars(#c_var{name=V}, Vs) -> add_element(V, Vs); 
 lit_vars(#c_cons{head=H,tail=T}, Vs) -> lit_vars(H, lit_vars(T, Vs));
+lit_vars(#c_bin{es=Es}, Vs) -> lit_list_vars(Es, Vs);
+lit_vars(#c_bin_elem{val=V,size=S}, Vs) -> lit_vars(V, lit_vars(S, Vs));
 lit_vars(#c_tuple{es=Es}, Vs) -> lit_list_vars(Es, Vs);
 lit_vars(Other, Vs) -> Vs.

(I don't know whether #c_bin_elem.type should be scanned as well).

-- Pascal Brisset




More information about the erlang-questions mailing list