Walter said:
It's hard to see a candidate being offered the job after trying that tactic.
Well then, that is the misfortune of the company.
I find it somewhat dichotomous how we programmers deal with extreme precision,
something that isn't precise usually doesn't work or worse, yet we allow
ourselves to be treated as morons and never attempt to establish what is really
intended by those that we work for.
My original response was somewhat facetious, intended to bring up some points
about the interviewing process and the capacity of the interviewer.
Honestly, if I were in an interview like that:
interviewer: <code snippet>, "what's wrong with this code?"
me: "Without knowing the specific requirements, it is hard to really determine
what is really 'wrong' as it looks like it would compile just fine to me. I do
see it resulting in undefined behavior when executing, however. Can you tell me
what the requirements are?."
interviewer: "I'll get to the requirements in a sec; what do you mean by
undefined behavior?"
me: "Well, there is a problem when derefrencing x because it hasn't been
initialized. The standard indicates that doing such results in 'undefined
behavior', so just about anything can happen at that point, but will probably
result in a crash."
interviewer: "By the way, the requirement was to 'write a program that exhibits
undefined behavior' -- nice job, you have been the only candidate to realize
that requirements are an important part to the development process."