News for hackers. Stuff that matters.
Re:Introducing a new, advanced Visual C++ code optimizer by Ono-Sendai on Thursday May 05, 2016 @08:07PM (#11640699)
Undefined behaviour allows faster code. It also allows handling of situations that would otherwise have to be defined in some 'awkward' way, such as throwing an exception on out-of-bounds array reads.

Edit: To add to my reply - for example, Java has almost no undefined behaviour. (The single exception AFAIK is some kind of multithreaded data race situation). The cost paid is that e.g. bounds checks must be done (in general) on array accesses, as the behaviour is defined to be an exception thrown in that case. Similarly for null reference dereferences.

Re:Introducing a new, advanced Visual C++ code optimizer by pjmlp on Friday May 06, 2016 @12:36PM (#11645060)
Yes, but for 99% of code written out there there is nothing to gain from faster code due to undefined behaviour.

I am coding since the mid-80's, always been a fan of Algol lineage of programming languages, with C++ being the only exception to it, as it allows many similar features.

Never have I had a situation where better performance thanks to undefined behaviour was an advantage for the use case we were trying to solve.

I think outside games, HPC and winning compiler benchmarks there hardly an advantage exploiting it.

Re:Introducing a new, advanced Visual C++ code optimizer by pcwalton on Friday May 06, 2016 @08:53PM (#11647797)
> Yes, but for 99% of code written out there there is nothing to gain from faster code due to undefined behaviour.

That's not true. Load-load forwarding benefits tons of code that isn't "games, HPC, or compiler benchmarks".

Re:Introducing a new, advanced Visual C++ code optimizer by pjmlp on Saturday May 07, 2016 @03:23AM (#11648730)
Sorry if I disagree.

If the solution delivered is within the time constrains required by the customer, any time spent optimizing ms out of the application is just wasted money.