News for hackers. Stuff that matters.
Re:My first verified imperative program by Jtsummers on Monday July 07, 2025 @02:27PM (#44493275)
> the algorithm will wrongfully report "false" for arrays like e.g. [INT_MIN, -1]

`INT_MIN + -1` is not 0 so it should report false in that case.

For UINT_MAX, the algorithm would need to be reconsidered, though, since it's written with signed integers in mind.

> Hopefully the proof would break if one tried to transfer it over?

Hopefully. The proof would have to be modified to account for the actual types. If you're using bounded integers you'd need to write a different proof.

Re:My first verified imperative program by derdi on Monday July 07, 2025 @03:32PM (#44493843)
> For UINT_MAX, the algorithm would need to be reconsidered, though, since it's written with signed integers in mind.

The algorithm is written assuming that unary - produces the additive inverse. That is also true for C's unsigned integers. -1U == UINT_MAX, -UINT_MAX == 1U. It Just Works.

Re:My first verified imperative program by junon on Monday July 07, 2025 @06:36PM (#44495296)
INT_MIN - 1 is undefined behavior in C.