Erlang/OTP Forums

Author Message

<  Erlang questions mailing list  ~  Strange behaviour of =:= applied to int and int64

Guest
Posted: Wed Sep 07, 2011 1:42 pm Reply with quote
Guest
I'm using R14B03 and writing a little NIF library. Today I've
encountered a strange behaviour of =:= when it is used against number
that is set in sources and term that was constructed as
enif_make_unit64. Here is an example:

(circa_dev@localhost)1> {ok, T} = ecirca:new(5, last, small).
{ok,{ecirca,#Ref<0.0.0.57>,<<>>,<0.48.0>,small}}
(circa_dev@localhost)2> {ok, A} = ecirca:size(T).
{ok,5}
(circa_dev@localhost)3> B = 5.
5
(circa_dev@localhost)4> A == B.
true
(circa_dev@localhost)5> A =:= B.
false
(circa_dev@localhost)6> A.
5
(circa_dev@localhost)7> B.
5

This behaviour looks quite weird to me. Is it expected?
_______________________________________________
erlang-questions mailing list
erlang-questions@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions
Post received from mailinglist
Guest
Posted: Wed Sep 07, 2011 5:49 pm Reply with quote
Guest
There was a recent thread related to the halfword emulator that would
cause this behavior. Not sure if its the same bug or not, but the
thread has a patch that fixed it for me.

Thread starts at [1] and the patch is at [2].


[1] http://erlang.org/pipermail/erlang-questions/2011-June/059650.html
[2] http://erlang.org/pipermail/erlang-questions/2011-June/059728.html

On Wed, Sep 7, 2011 at 9:49 AM, Dmitry Groshev <lambdadmitry@gmail.com> wrote:
>>Is it possible that you've made a "big" integer with a value of 5 in
> your NIF
> I'm not sure how BEAM handle enif_make_uint64, but I think that it would be
> strange if BEAM represent such numbers as "big integers".
> Anyway, it's a clear abstraction leak.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@erlang.org
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
_______________________________________________
erlang-questions mailing list
erlang-questions@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions
Post received from mailinglist
Guest
Posted: Thu Sep 08, 2011 1:58 pm Reply with quote
Guest
I'm more interested in fixing this behaviour in future releases than patching BEAM myself, because I can easily avoid this error. Is there any hope for this?
Post received from mailinglist
Guest
Posted: Thu Sep 08, 2011 2:18 pm Reply with quote
Guest
> I'm more interested in fixing this behaviour in future releases than
> patching BEAM myself, because I can easily avoid this error. Is
> there any hope for this?

Yes, the patch in question has been applied to the dev branch:

https://github.com/erlang/otp/blob/dev/erts/emulator/beam/erl_nif.c

and will thus appear in R14B04, due to be released on 5th October IIRC.

Regards,
--
Magnus Henoch
Erlang Solutions Ltd
http://www.erlang-solutions.com/
_______________________________________________
erlang-questions mailing list
erlang-questions@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions
Post received from mailinglist
Guest
Posted: Fri Sep 09, 2011 4:43 pm Reply with quote
Guest
Magnus Henoch wrote:
>> I'm more interested in fixing this behaviour in future releases than
>> patching BEAM myself, because I can easily avoid this error. Is
>> there any hope for this?
>>
>
> Yes, the patch in question has been applied to the dev branch:
>
> https://github.com/erlang/otp/blob/dev/erts/emulator/beam/erl_nif.c
>
> and will thus appear in R14B04, due to be released on 5th October IIRC.
>
> Regards,
>
The mentioned patch in dev for R14B04 does only apply for halfword emulator:

https://github.com/erlang/otp/commit/1c0966044b66d20f3f6607e91076e0a61918f1a4

So... are you running halfword emulator, Dmitry.

/Sverker, Erlang/OTP

_______________________________________________
erlang-questions mailing list
erlang-questions@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions
Post received from mailinglist
Guest
Posted: Fri Sep 09, 2011 4:48 pm Reply with quote
Guest
yes.
Post received from mailinglist

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum