On Mon, 29 Oct 2012 09:35:00 EDT erik quanstrom <[email protected]>  wrote:
> On Mon Oct 29 05:47:10 EDT 2012, [email protected] wrote:
> > http://news.ycombinator.com/item?id=4711346
> > 
> > 9fans says, ``no room in the compiler world for amateurs''. what's your tak
> e 
> > on the above fubar?
> 
> any sort of "advanced" code-moving optimization is confusing.  but the
> way c/c++ are used in linux, bsd & osx, there is a noticable benefit to
> optimizing calls away.  it takes smarts to optimize away those recursive
> wrapper macros.  so they're in a bit of a pickle.

It has nothing to do with "how" C/C++ are used in linux, bsd &
osx -- you forgot windows!  The C standard allows a lot of
leeway in optimization.  Consider this:

        foo() {
            ...
            int x;
            int y[10];
            ...
            memset(y, 0, sizeof y);
        }

If x is never referred to, a correct program will never notice
if it is taken away. If address of x is never taken, it can be
allocated in a register (if there is a free one) to improve
performance. The same reasoning can be used to elide memset()
on y. Where do you draw the line? Any line will be arbitrary.

What the blog writer wanted to do (clearing memory after use)
is *not* guaranteed by the C standard so he can't expect help.
But it is easy to fool compilers to do what he wanted -- just
calling a user defined function that in turn calls memset did
the trick with gcc.

> it goes without saying, i think a compiler that largely does what you
> ask it to optimizes the scarce resource: developer time.

That is a separate issue.

Reply via email to