|
On Sep 16, 2014 1:42 AM, "Tim Hill" <drtimhill@gmail.com> wrote:
> One of my interview questions for a C applicant is:
>
> int k = 1;
> k = k++ + ++k;
>
> What is the value of k?
In my experience, "not what the coder expected." The pattern is less obvious when it's a result of aliasing. But if I see it happening, I just assume undefined behavior, and try to figure out what the intent was so I can rewrite.
This is my answer to quizzes about operator precedence too: "if you have to ask, you need more parens." :-)