Re:Bounded Integer: Header-only C++ library replaces integer...
by leni536 on Sunday September 29, 2019 @11:13AM
(#21107486)
You should never rely on the underlying CPU architecture's behavior on integer overflow when you write C or C++. It is undefined and not unspecified or implementation defined.
[ Parent
| on HN ]
Re:Bounded Integer: Header-only C++ library replaces integer...
by tom_ on Sunday September 29, 2019 @02:18PM
(#21108676)
Undefined behaviour is undefined only by the standard - an implementation may choose to handle undefined behaviour in some documented, specific fashion. Undefined behaviour exists to give implementations exactly this flexibility.
Re:Bounded Integer: Header-only C++ library replaces integer...
by leni536 on Sunday September 29, 2019 @04:37PM
(#21109471)
> an implementation may choose to handle undefined behaviour in some documented, specific fashion
Or they can leave it undefined and not make any guarantees. I do not think that any compilers on any platform makes any guarantee on signed overflow.
Re:Bounded Integer: Header-only C++ library replaces integer...
by leetcrew on Sunday September 29, 2019 @12:08PM
(#21107830)
true, but the behavior of unsigned integers is defined such that they can't overflow. the "wrapping" behavior of unsigned ints is defined: you get the arithmetic result modulo the max value for that width.