C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Integers are all two's complement, so now overflow is predictable

From: Anoop Rana <ranaanoop986_at_[hidden]>
Date: Fri, 7 Apr 2023 17:04:36 +0530
Refer to Why is Signed Overflow due to computation still Undefined Behavior
in C++20
<https://stackoverflow.com/questions/70801443/why-is-signed-overflow-due-to-computation-still-undefined-behavior-in-c20>
where there some discussion on this.

On Fri, 7 Apr 2023 at 16:51, Frederick Virchanza Gotham via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> Since the latest Standard now dictates that signed integers are
> implemented in two's complement, can we now do away with signed
> overflow being undefined behaviour?
>
> How about the following being true for all compilers?
>
> int i = INT_MAX;
>
> ++i;
>
> static_assert( INT_MIN == i );
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2023-04-07 11:34:49