News for hackers. Stuff that matters.
Re:Bounded Integer: Header-only C++ library replaces integer... by pjc50 on Sunday September 29, 2019 @11:25AM (#21107556)
.... However, unless you use non portable intrinsics, you can't make the compiler use MMX. So in practice you get wrap on overflow.

Worse, the compiler is entitled to use saturation arithmetic if you've assumed wrapping.

Re:Bounded Integer: Header-only C++ library replaces integer... by jstanley on Sunday September 29, 2019 @12:06PM (#21107812)
> Worse, the compiler is entitled to use saturation arithmetic if you've assumed wrapping.

C89 (draft[1], because the actual spec is not public) section 3.1.2.5 states:

> ... a result that cannot be represented by the resulting unsigned integer type is reduced modulo the number that is one greater than the largest value that can be represented by the resulting unsigned integer type.

So, unless I'm misunderstanding, the compiler is not entitled to use saturation arithmetic on unsigned integers.

[1] http://port70.net/~nsz/c/c89/c89-draft.html

Re:Bounded Integer: Header-only C++ library replaces integer... by ncmncm on Sunday September 29, 2019 @03:22PM (#21109106)
signed and unsigned have different semantics.

The compiler is allowed to do literally anything on signed overflow, including launching the missiles, and not running the program. Or both.

Re:Bounded Integer: Header-only C++ library replaces integer... by gpderetta on Sunday September 29, 2019 @11:52AM (#21107714)
You can build portable libraries on top of nonportable primitives.