[erlang-bugs] enif_make_int64 => -0 for INT64_MIN with gcc 4.9.1

Tomas Abrahamsson tomas.abrahamsson@REDACTED
Sun Jul 20 03:27:29 CEST 2014


Hi,

I upgraded gcc from version 4.8.1 to 4.9.1, recompiled Erlang/OTP-17.1.1
and my nif, and now enif_make_int64 creates -0 for INT64_MIN.

  % make test
  erl -s int64nif go -s erlang halt
  Erlang/OTP 17 [erts-6.1.1] [source] [smp:4:4] [async-threads:10]
[kernel-poll:false]

  -0

When Erlang was compiled with gcc-4.8.1, it printed -9223372036854775808,
I've attached the test programs, here are the important lines:

    go() ->
        io:format("~p~n", [int64_from_nif()]).

The NIF C-code contains:

    static ERL_NIF_TERM
    int64_from_nif(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[])
    {
        return enif_make_int64(env, INT64_MIN);
    }

System information:

  OS: linux, 32-bit core i5, 3.14-1-686-pae (debian unstable)
  Erlang/OTP: built from scratch (both times) from the OTP-17.1.1 git tag.
  gcc: initially: gcc (Debian 4.8.1-10) 4.8.1
       with this one, it prints -9223372036854775808
  gcc: after upgrade: gcc (Debian 4.9.1-1) 4.9.1
       with this one, it prints -0

The only change I did was apt-get install gcc and then rebuilding Erlang.

BRs
Tomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: int64nif.tar.gz
Type: application/x-gzip
Size: 851 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20140720/de1f2c08/attachment.bin>


More information about the erlang-bugs mailing list