Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Isn't this line from #3, undefined behavior not mentioned in the article (sequence point violation)

zp++ = xp + *yp;



That's not a sequence point violation. The C standard makes it clear that zp gets xp + *yp prior to the increment. Quoting 6.5.2.4

> The result of the postfix ++ operator is the value of the operand. After the result is obtained, the value of the operand is incremented. (That is, the value 1 of the appropriate type is added to it.) See the discussions of additive operators and compound assignment for information on constraints, types, and conversions and the effects of operations on pointers. The side effect of updating the stored value of the operand shall occur between the previous and the next sequence point.

The last sentence is key.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: