Date: Fri, 28 Apr 2023 11:42:29 +0100
On Fri, Apr 28, 2023 at 8:42 AM Bo Persson via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> > If that's the only reason why signed overflow is UB,
>
> It's not.
>
> No wrap around also lets the compiler assume that a < a + 1 is always
> true. Useful for loop conditions.
Well then let's make an exhaustive list of all the reasons why signed
overflow is UB.
I've already proposed a solution to the 'double negative' problem,
i.e. -(-INT_MIN) == INT_MIN
With regard to "a < a + 1" being always true, well then in the future
it can sometimes be negative. If you don't want this to happen then I
think you're using the wrong tool. I do realise that a massive
proportion of C++ programmers use a signed integer type when an
unsigned would be adequate, but individual programmers will just have
to iron out their own bad habits.
<std-proposals_at_[hidden]> wrote:
>
> > If that's the only reason why signed overflow is UB,
>
> It's not.
>
> No wrap around also lets the compiler assume that a < a + 1 is always
> true. Useful for loop conditions.
Well then let's make an exhaustive list of all the reasons why signed
overflow is UB.
I've already proposed a solution to the 'double negative' problem,
i.e. -(-INT_MIN) == INT_MIN
With regard to "a < a + 1" being always true, well then in the future
it can sometimes be negative. If you don't want this to happen then I
think you're using the wrong tool. I do realise that a massive
proportion of C++ programmers use a signed integer type when an
unsigned would be adequate, but individual programmers will just have
to iron out their own bad habits.
Received on 2023-04-28 10:42:42