News for hackers. Stuff that matters.
Re:Impact of Undefined Behavior on Performance by fay59 on Friday July 09, 2021 @10:40AM (#27784140)
You could also take a measured approach and, like rust, just define signed overflow to wrap. UB and its current interpretation is not worth whatever small sliver of performance the current implementation of LLVM appears to give you.
Re:Impact of Undefined Behavior on Performance by UncleMeat on Friday July 09, 2021 @12:35PM (#27785520)
I don't agree that this is measured. It has a few big problems.

1. Basically no developer actually wants it to wrap. This is almost certainly a logical bug that just pushes the problem a few statements further into the program.

2. Defining it to wrap means that you need software checks for architectures that don't support hardware wrapping on the same width as the integer type. This means that all programs get slower when targeting these architectures. This isn't a "sliver of performance". It is a software branch at almost every integer operation. This approach is not especially well loved in the C/C++ communities.