Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The question is "what would the return value be," and without knowing which compiler is used you don't know what it would return. It doesn't make sense to say the program returns "undefined behavior" or "implementation-dependent."

You might be taking issue with the question itself, but I think it's a valid question because C compilers tend to be lenient with what they compile.



I can't know != I don't know


Yes, and "I can't know" is a stronger assertion than "I don't know". The former implies the latter. However, both are correct.


Thing is I can know if the necessary information is provided (i.e. CPU architecture, version of the standard). Portability is a feature of C, but C's portability is mostly syntactic and only partly semantic.


But if the necessary info isn't provided, you don't know because, as you say, you can't know.

It's semantics. On many exams, "don't know" is a correct answer when you can't know because info is intentionally left out.


I don't really want to be a pedant here, but in this case if the necessary information was provided, I had the knowledge to find a correct answer. This is different from the case where even if the information was provided I wouldn't be able to know because I don't have the necessary knowledge.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: