[erlang-bugs] Pattern matching of floats does not work in the shell

Paul Guyot <>
Sat Sep 3 20:05:34 CEST 2011

Le 3 sept. 2011 à 12:40, Robert Virding a écrit :

> You sure you are getting all the right standard libraries? Otherwise it could be architecture related. But you mentioned that it worked compiled which would mean that it is NOT architecture related. Weird.

After further analysis, the bug is in HiPE and occurs in eval_bits.erl (hence the issue in the shell).
It can be reproduced with the following function:

bin_to_float(B,S) ->
    <<F:S/float>> = B,

I only tried the following simpler case, which works (except in the shell, where it is interpreted to eval_bits:get_float/3 which is like bin_to_float/2 above):

bin_to_float(B) ->
    <<F:64/float>> = B,

bin_to_float/1 always work. bin_to_float/2 works when the module is compiled without native, but fails when it is compiled +native.

The reason why you could not reproduce the bug is that all my installations are configured with --enable-native-libs, and therefore, module eval_bits is compiled +native. You probably did not pass --enable-native-libs on your Mac.

The bug is a typo in lib/hipe/icode/hipe_beam_to_icode.erl. I'm submitting a patch.

Semiocast            http://semiocast.com/
+33.183627948 - 20 rue Lacaze, 75014 Paris

More information about the erlang-bugs mailing list