Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

In practice, there is no such thing as "no optimization" in C.

If you map every variable read to a memory read and every variable written to a memory store, your code will run incredibly slow. At the least, you will want to do register allocation and constant folding.

That's not so bad w.r.t. undefined behavior, but you also will want to do dead code elimination. If you don't, program size will blow up (think of macro definitions for DEBUG) That dead code elimination is what causes many of those portability issues.

In C, undefined behaviour is the price we pay for small code size and fast execution.

Also, are you sure C# doesn't optimize code marked DontOptimize? I'm asking because the documentation at http://msdn.microsoft.com/en-us/library/system.runtime.compi... says "The method is not optimized by the just-in-time (JIT) compiler or by native code generation (see Ngen.exe) when debugging possible code generation problems.", but doesn't tell what that last phrase means.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: