[PATCH] memset 0 in obscure is optimized away by compiler

Cathey, Jim jcathey at ciena.com
Wed Apr 16 20:08:56 UTC 2014


>Even if optimizer throws out the call to memset function the
>compiler shall create code to fill the pwd array before it's
>freed. Otherwise I consider the optimizer behaving wrong.

If the compiler is 'smart' enough to know what memset() does,
what's from preventing it from also knowing what free() does?  If
it proceeds based upon _standard_ definitions of both of these
functions it _is_ justified in eliminating the memset() altogether.

Standard definition of free is: "I will no longer use this memory
buffer for _anything_."  The optimizer can then roll up the code
backwards 'til the point where it decides you last did 'use' it.

Mind you, I don't think I like my compiler being quite that 'smart'.
I would hope there was a knob someplace to tell it not to be quite
so, umm, _free_ with free()!

-- Jim



More information about the busybox mailing list