man 3 switch

Michael Hennebry hennebry at web.cs.ndsu.nodak.edu
Mon Nov 16 20:54:36 UTC 2009


On Mon, 16 Nov 2009, Rick Stevens wrote:

> On 11/14/2009 01:55 PM, Frank Cox wrote:

>> As C is an ISO standard, I sincerely doubt there would be any difference in 
>> the
>> syntax and behaviour of the keywords between C compilers on any Unix-like
>> operating system.
>
> Incorrect.  C, for example, does not guarantee the order of evaluation
> of arithmetic operators of equal precedence in the same statement (in

It does in the example given.
Binary + associates left to right.

> other words, is something like "a + b + c" evaluated left to right, or right 
> to left?).  This can have significant effects if some of the
> operands have "side effects"

(a+b)*(b+a) could be ambiguous.
Either sum could be performed first.
If their are side effects, order could matter.

Order could also matter if floating point is involved.
C89 doesn't require much of floating point.
It doesn't even require that the same expression with
the same data produce the same number each time.

The following function could return 1:

int fred(float a, float b)
{
int result=0;
for(int j=0; j< 10; ++j) result+=(1f< a*b);
return result;
}

I would hope not.

> Another example is that a null pointer (or the value "NUL") is not
> necessarily zero, only that it is guaranteed to not point at any valid
> datum.
>
> C allows quite a bit of leeway to the compiler implementation.

-- 
Michael   hennebry at web.cs.ndsu.NoDak.edu
"Pessimist: The glass is half empty.
Optimist:   The glass is half full.
Engineer:   The glass is twice as big as it needs to be."




More information about the users mailing list