News for hackers. Stuff that matters.
Re:C and C++ Prioritize Performance over Correctness by gavinhoward on Friday August 18, 2023 @03:17PM (#37180696)
Correct.

I have routines that take the unsigned values and interpret them as signed, two's-complement values.

So you would write this:

    val = temp1 + temp2;
    if (y_ssize_lt(val, temp1)) y_trap();
That `y_ssize_lt()` function computes whether `val` is less than `temp1` as though they were signed, two's-complement integers. But because they are actually unsigned, the compiler cannot be malicious and delete that code.
Re:C and C++ Prioritize Performance over Correctness by kragen on Friday August 18, 2023 @03:55PM (#37181226)
i see, thanks

maybe we should develop a nonmalicious compiler

Re:C and C++ Prioritize Performance over Correctness by gavinhoward on Friday August 18, 2023 @09:41PM (#37184593)