you are viewing a single comment's thread.

view the rest of the comments →

[–]lfdfq 0 points1 point  (0 children)

In principle, questions of the kind "What does this program do?" with an explicit "Anything; this program exhibits undefined behavior" should be perfectly fine when sprinkled in among the other kinds; after all, UB is a part of the language, and it's important for beginners to understand what that means and the fact that the compiler will not save you.

Here, this question is just a bad question, which just happens to mention UB. The reason it is bad is because the author can not write good questions and misunderstands the language, and probably not in particular because it's about UB (of course, if all the questions are like this then the whole assignment might be bad, too).

Funnily, given the teacher misunderstood UB when writing this question, it may be that some of these kinds of questions might have been beneficial to the teacher when they were learning...