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

Harald Becker ralda at gmx.de
Wed Apr 16 20:29:09 UTC 2014


Hi Jim !

>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()!

That knob is part of the function definition. on a standard
function definition like:

void free( void* ptr );

with function free not part of the current source module, no
compiler shall expect anything about how memory is used in the
free function. The problem is such definitions get overwritten by
header files (possibly by compiler specific header files). If you
look in there in detail you may find additional options telling
the compiler to do extra optimization. call your function myfree
and link in a file with:

void myfree( void* ptr )
{
  free( ptr );
}

... and you get your expected knob :)

--
Harald


More information about the busybox mailing list