[erlang-patches] Re: [erlang-bugs] HiPE bug with comparison of floats with integers

Niclas Axelsson burbas@REDACTED
Wed Feb 2 17:15:36 CET 2011


On 02/02/2011 11:50 AM, Kostis Sagonas wrote:
> Paul Guyot wrote:
>> Hello,
>>
>> There is a bug in HiPE compilation with the comparison of floats with 
>> integers.
>> This bug happens with the following two functions:
>>
>> ------
>> -module(hipe_zero).
>> -export([f/1, g/2]).
>>
>> f(X) ->
>>     Y = X / 2,
>>     Y == 0.
>>
>> g(X, Z) ->
>>     Y = X / 2,
>>     case Z of
>>         test when Y == 0 -> test_zero;
>>         test -> test_non_zero;
>>         other -> other
>>     end.
>> ------
>>
>> Beam will evaluate hipe_zero:f(0) and hipe_zero:f(0.0) to true, while 
>> HiPE will evaluate hipe_zero:f(0) and hipe_zero:f(0.0) to false. HiPE 
>> properly evaluates hipe_zero:f/1 to true if passed 
>> {icode_inline_bifs, false}. However, not inlining the '==' bif just 
>> masks the bug as HiPE does not properly evaluate hipe_zero:g(0, test) 
>> to test_zero.
>
> This has now been fixed.  The relevant fetch command is:
>
>    git fetch git://github.com/kostis/otp.git icode-range-fix
>
> If one wants to apply the change manually to a previous OTP version, 
> the last commit on that branch shows the fix that needs to be applied 
> (basically change two calls in hipe_icode_range.erl from lists:any/2 
> to calls to lists:all/2).
>
> Thanks to Paul for reporting this.
>
> Kostis
>
> ________________________________________________________________
> erlang-patches (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-patches-unsubscribe@REDACTED
Thanks Kostis and Paul,

The patch is now included into 'pu'.

Regards,
Niclas Axelsson, Erlang/OTP


More information about the erlang-patches mailing list