[clug] Code question: Why doesn't this seqfault (kernel/printk.c)

David Price david.price at anu.edu.au
Mon Oct 20 12:39:38 EST 2003


On Mon, Oct 20, 2003 at 12:32:16PM +1000, Darren Freeman wrote:
> IIRC there is no guarantee in C that this is the case, although it's
> often true.

Just went looking for a copy of the standard, found one at:
http://www.cl.cam.ac.uk/~mgk25/volatile/ISO-C-FDIS.1999-04.pdf

Page 89 (ps page 101) has this to say:

Unlike the bitwise | operator, the || operator guarantees
left-to-right evaluation; there is a sequence point after the
evaluation of the first operand. If the first operand compares unequal
to 0, the second operand is not evaluated.

David



More information about the linux mailing list