Compiler bug in Erlang R7B-1 (bit syntax)

Robert Virding rv@REDACTED
Wed Dec 20 14:57:37 CET 2000


Pascal Brisset <Pascal.Brisset@REDACTED> writes:
>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:
>
...
>
>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).

No, the fix is fine, there is no need to check anything but the val and 
size fields.  Without the fix the compiler doesn't detect that X is 
used after the case, and, therefor, produces no code to export it.

The patch will be in the next release.

	Robert





More information about the erlang-questions mailing list