Live data from Hacker News

A glimpse of undefined behavior in C

blog.chris-cole.net

1–10 of 67 posts

Re: A glimpse of undefined behavior in C

#7
Knowing how exactly sequence points work might be an advanced topic, but I am not sure I'd hire a junior C/C++ programmer if he has not heard of sequence points. If somebody has, then he clearly won't do something like this code. I am not 100% sure in how they work either (haven't programmed C for 4 years), so I just avoid these kind of unnecessary complications in the code, if not for myself, then for the guy who comes after me, and who, if he has a bad day, may inadvertently cause some trouble.

Really, that's one of the reason why Java still works well at big companies. The code is usually so verbose and 'un-smart' that it's quite hard for programmers with minority complex to obfuscate it when they're trying to prove that they're smart. It's a shame however that if the language is primitive then you can always create a big framework to obfuscate stuff. :)

Re: A glimpse of undefined behavior in C

#8
post #6

The way I learned that in C a long time ago was "post increment" was "post statement increment".

exactly. This is precisely to spec; and I got the answer of 60 immediately on looking at the code.

This is incorrect; it is undefined behavior according to the spec: http://www.reddit.com/r/programming/comments/1rrefp/a_glimps...

Re: A glimpse of undefined behavior in C

#9
post #8
post #6

Earlier quoted context omitted.

exactly. This is precisely to spec; and I got the answer of 60 immediately on looking at the code.

This is incorrect; it is undefined behavior according to the spec: http://www.reddit.com/r/programming/comments/1rrefp/a_glimps...

Ok, so do any other compilers handle it differently?
Post reply on HN