On Mon, May 8, 2017 at 6:24 PM, James McCoy <[email protected]> wrote:
> On Mon, May 08, 2017 at 03:08:31PM -0500, R0b0t1 wrote:
>> Or, *instead of all of the above,* arithmetic can be defined to wrap.
>> Technically, with no other changes, this doesn't solve the original
>> complaint about undefined behavior
>
> It would, because it would be defined to wrap.  That's trivial to
> implement with GCC by building with `-fwrapv`, but I'm not sure how many
> other compilers provide a similar flag.
>

The distinction I meant to point out is that the implementation wraps
the arithmetic, but if it doesn't you would have to do it yourself if
the code aims to be portable.

Per the documentation: "This option instructs the compiler to assume
that signed arithmetic overflow of addition, subtraction and
multiplication wraps around using twos-complement representation."

It doesn't implement wrapping arithmetic, it just assumes that
arithmetic does wrap.

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui