assume, assert, enforce, @safe

Daniel Murphy via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 31 10:26:35 PDT 2014


"Daniel Gibson"  wrote in message news:lrdnri$2fge$1 at digitalmars.com...

> One could write a memset_s oneself.. that does a memset, reads the data 
> and writes a char of it or something to a global variable (hoping that the 
> compiler won't optimize that to "just set that variable to 0").

Some compilers will do exactly that optimization.

> The thing is: I don't want a compiler to remove code I wrote just because 
> it "thinks" it's superfluous.
> It could tell me about it as a warning, but it shouldn't just silently do 
> it. If removing code makes my code faster, I can do it myself.

No you don't, no you can't.  You are using an optimizer because writing it 
in the perfectly precise, perfectly fast way makes your code unmaintainable. 
You want the optimizer to delete all those never-read initializations, drop 
all those temporary variables, and turn your multiplies into shifts and 
additions.

If you didn't, you wouldn't be using an optimizer. 



More information about the Digitalmars-d mailing list