[erlang-bugs] erlang:phash2/1 isn't architecture-independent?

Hans Bolinder hans.bolinder@REDACTED
Mon Jan 28 14:36:12 CET 2008


[Scott Lystig Fritchie:]
> Using R11B-5 on both i386 and amd64 platforms, I see that
> erlang:phash2/1 yields different values.

phash2/1 is broken on 64-bit platforms. Thanks for reporting this bug!

Best regards,

Hans Bolinder, Erlang/OTP team

*** bif.c	Mon Jan 28 14:25:22 2008
--- /clearcase/otp/erts/erts/emulator/beam/bif.c	Mon Jan 28 13:47:02 2008
***************
*** 3624,3630 ****
      Uint32 hash;
  
      hash = make_hash2(BIF_ARG_1);
!     BIF_RET(make_small(hash & MAX_SMALL));
  }
  
  BIF_RETTYPE phash2_2(BIF_ALIST_2)
--- 3624,3630 ----
      Uint32 hash;
  
      hash = make_hash2(BIF_ARG_1);
!     BIF_RET(make_small(hash & ((1L << 27) - 1)));
  }
  
  BIF_RETTYPE phash2_2(BIF_ALIST_2)



More information about the erlang-bugs mailing list