Re: enif_make_int64 => -0 for INT64_MIN with gcc 4.9.1

Lukas Larsson <[email protected]>
Newsgroups gmane.comp.lang.erlang.bugs
Message-ID <[email protected]>
On 15/08/14 10:42, Mikael Pettersson wrote:
> Lukas Larsson writes:
>   > On 14/08/14 20:06, Tuncer Ayaz wrote:
>   > > Just started building maint and I've been seeing this:
>   > > beam/bif.c:2824:5: runtime error: signed integer overflow:
>   > > 429496729 * 10 cannot be represented in type 'int'
>   > >
>   > Yeah I saw that one, but since we use n to determine if we are to use i,
>   > i will never be used while overflowed.
>
> That's unfortunately the wrong way to think about signed overflow in C.
> It is _never_ about whether the computed value is used or not; the mere
> fact that overflow occurred causes undefined behaviour (UB).  Furthermore,
> the worst consequence of UB is not that the HW does something wrong, it's
> that the compiler(s) can validly assume that UB doesn't occur, and transform
> the code accordingly.  And GCC _will_ do that unless you tell it not to.

Thanks for pointing this out! It would appear that when I hit UB, 
deamons might fly out of my nose. I'll fix the other UBs I've found as well.

Lukas
_______________________________________________
erlang-bugs mailing list
[email protected]
http://erlang.org/mailman/listinfo/erlang-bugs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.