5/14/2026 at 2:30:14 AM
The code in the post seems very similar to the one in my own post from 2010: https://susam.net/sequence-points.html int a = 5;
a += a++ + a++;
I guess this specific code (with a = 5) was very popular back then. I do remember that these kinds of questions used to be popular interview questions. I found them quite annoying because if you really wanted the job, answering them felt like a gamble: Should you accurately say it is undefined behaviour? Would the interviewer know that? Or does the interviewer expect the output produced by the Visual Studio C compiler? Or do they expect the output produced by gcc? Which version of the compiler? Which compiler?The moment such a question appeared, your chances of answering it in a way that would satisfy the interviewer immediately dropped to somewhere around 20%. Probably even lower. And if you decided to answer accurately, the odds are even worse because most interviewers I stumbled upon did not care about nor understand 'undefined behaviour' or 'sequence points'. I chose to answer accurately every time and, more than once, that left the interviewer flummoxed.
I am very glad these types of interview questions have become less prevalent these days. They have, right? Right?
by susam