alt.hn

5/12/2026 at 2:14:04 PM

Int a = 5; a = a++ + ++a; a =? (2011)

https://gynvael.coldwind.pl/?id=372

by e-topy

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

5/12/2026 at 2:31:10 PM

Perhaps I'm just naive and/or have forgotten too much C, not that I knew that much, but I'm a bit perplexed as to why this is UB.

It seems like something that should trigger a "we should specify this" reaction when adding these operators, and there is at least one reasonable way to define it which is fairly trivial and easily implementable.

by magicalhippo

5/12/2026 at 2:28:01 PM

Some C++ quiz with ++a and a++? It‘s always about sequence points, or better the lack of sequence points.

It‘s the standard technical C++ blog post everybody seems to write.

by Tomte

5/12/2026 at 2:22:56 PM

Oh god. How long before yet another UB-based question ends up in technical coding interviews?

by nDRDY