3 ms·
Well, I would guess that since memset() is a well-known standard library function that actually has a specification, and its buffer argument is not volatile, th
by unwind 13y ago
Well, I would guess that since memset() is a well-known standard library function that actually has a specification, and its buffer argument is not volatile, then the compiler can "get away" with assuming things.
It's the same for e.g. strcmp() and strcpy(), they can be compiled into specialized instructions when the compiler considers that a win.
GCC's set of builtins is quite large: http://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html http://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html.
To comment on the (very interesting) article, I think this:
XDR *xdrs = &clp->xdr_stream;
is not at all an error, even if clp is NULL. No de-referencing occurs, since the expression is just the argument of the & (address-of, in C) operator. See the traditional offsetof() definition: http://en.wikipedia.org/wiki/Offsetof http://en.wikipedia.org/wiki/Offsetof which explicitly does this for a base pointer of 0.