c - Sequence points and order of evaluation -



c - Sequence points and order of evaluation -

i reading through k&r , came across illustration uncertainty in behavior while evaluating look a[i]=i++; c99 spec in $6.5.2 says that

between previous , next sequence point object shall have stored value modified @ 1 time evaluation of expression. furthermore, prior value shall read determine value stored.

the above illustration k&r holds on first statement. please explain how fail on second.

does standard says order of evaluation of sub-expressions in case of sequence points beingness involved. eg. a[i++] || b[i++]. know these evaluated left right how can derived above statement or explicitly stated in standard somewhere ?

does standard says order of evaluation of sub-expressions in case of sequence points?

the order of evaluation defined in case of conditional operators && || , reason short circuiting works.

it explicitly specified c99 standard.

reference: c99 standard

annex j: j.1 unspecified behavior

1 next unspecified: .....

the order in subexpressions evaluated , order in side effects take place, except specified function-call (), &&, ||, ?:, , comma operators (6.5). .....

further in, 6.5.14 logical or operator

4) unlike bitwise | operator, || operator guarantees left-to-right evaluation; there sequence point after evaluation of first operand. if first operand compares unequal 0, sec operand not evaluated.

as logical and:

6.5.13 logical , operator

unlike bitwise binary & operator, && operator guarantees left-to-right evaluation; if sec operand evaluated, there sequence point between evaluations of first , sec operands. if first operand compares equal 0, sec operand not evaluated.

c undefined-behavior language-lawyer

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -