News for hackers. Stuff that matters.
Re:What Every C Programmer Should Know About Undefined Behav... by repsilat on Thursday May 12, 2011 @08:52PM (#2543018)
> it's better to crash hard and fast

I'm not so sure about that. If you need to squeeze out a little more performance, code that is "technically undefined" can be more portable than dropping to ASM.

I think LLVM should emit a warning on code with undefined semantics and generate DWIM instructions instead of UD2s.

Re:What Every C Programmer Should Know About Undefined Behav... by ToastOpt on Friday May 13, 2011 @04:10AM (#2543976)
It really depends on your motives. If you will be needing to port to new platforms in the future, it's better to have a hard-and-fast crash now, so you can learn and avoid the undefined behavior now, rather than face a large bug backlog years down the line.

But you're correct that sometimes it can be expedient to exploit such technically undefined behavior. (I've committed this sin myself, most commonly in serializers/deserializers)