Julie said:
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."
Yeah, it's a good point, and I had a laugh. But remember, you should
always answer a question from the point of view of the questioner.
Questions are always asked in a vast context that exists at the time
of the interview, as opposed to the threadbare context that exists in
a newsgroup posting. It is unlikely that the interviewer would want
to know about language correctness or program requirements. If the
interviewee did quibble about these, the interviewer would most likely
think the candidate is being snobbish and wasting their time.
Creativity is good, but not when someone is asking you questions and
expecting certain responses. This is especially true in an interview,
because people tend to hire other people who think like themselves.
If I were interviewing, I would ask them what are the four components
of the stack frame created by a function call.
Answer:
return address
saved machine state
copies of function parameters
space for local variables