[Gllug] C function strcasecmp

home at alexhudson.com home at alexhudson.com
Sun Jul 29 19:02:56 UTC 2001


On Sun, Jul 29, 2001 at 06:44:40PM +0100, Nix wrote:
> >> > > 	*x+=~(*x)++;
> >> > 
> >> > Foul and invokes undefined behaviour; multiple modifications with no
> >> > intervening sequence points ;P
> > Actually, thinking about it - who cares if it's out of sequence? Doesn't
> > matter :) (I think - assuming it wasn't being calculated in parallel,
> > anyway).
> 
> You misunderstand the meaning of `undefined'. It doesn't mean
> *anything*; it's not in C. The compiler is quite within its rights to
> generate code that reformats the disk, or that runs nethack; it doesn't
> just affect order-of-execution.

I don't think it is within it's rights to do that. The only issue here is
the postincrement, surely? Which is a non-issue in this instance. Given the
code compiles cleanly, even -Wall -pedantic, I think that pretty much makes
it valid C. I disagree with your definition of undefined in this instance
also - while that could apply to APIs, I don't see how that applies to
language constructs. I also can't find any reference to that definition in
the C standards - where did you find it?

> (Also, think what would happen if `x' needed multiple instructions to
> address, there was a carry, and the system reordered execution so that
> the += was done (perhaps partially) before the addition.

I don't think that happens even in bigmath. We're surely only concerned with
operator precedence here?

Cheers,

Alex.

-- 

-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list