Re: strcpy - my implementation



On Sep 9, 5:34 pm, CBFalconer <cbfalco...@xxxxxxxxx> wrote:
Keith Thompson wrote:
    if (c) { ... }
    if (c != '\0') { ... }

I disagree. The (c) expression worries only about whether the
character is or is not something with a zero value.  The (c !=
'\0') expression expressly converts that zeroness into either the
value 0 or the value 1 before testing.  Optimization may affect
this.

I would normally expect the second expression to generate larger
code than does the first, with optimization disabled.

I don't know what you're smoking today, but
the above two if statements are exactly
equivalent in effect, and I challenge you
to come up with a compiler that generates
different code for them, let alone one that
actually causes a different code branch to
execute.

.



Relevant Pages


Loading