News for hackers. Stuff that matters.
Re:The Value of Undefined Behavior by iainmerrick on Saturday July 21, 2018 @05:33PM (#17583980)
If these are the best justifications we can come up with, it doesn't change my opinion that the current reliance on UB by compilers is a bad idea. Anyone got any better ones?
Re:The Value of Undefined Behavior by saagarjha on Sunday July 22, 2018 @01:20AM (#17585388)
It makes your code many times faster in a lot of cases?
Re:The Value of Undefined Behavior by iainmerrick on Sunday July 22, 2018 @04:27AM (#17585838)
This article gives two examples where UB arguably helps you, and in each case the article itself mentions a cleaner and better way of doing it.

Magic behavior of "int" (but not "unsigned int") --> just use a type that's the correct size and better conveys your intention, like "size_t".

(And that one doesn't make your code "many times faster", in the example given it saves a single instruction.)

Type-based assumptions about aliasing (with a special case for char*) --> be explicit about your intention with the "restrict" keyword.