4 ms·
>Did he make sure the behavior he mentioned is uniform across all ISO standards? I don't know. >What is his source for coming up with a certain answer to a ce
by sjolsen 12y ago
>Did he make sure the behavior he mentioned is uniform across all ISO standards?
I don't know.
>What is his source for coming up with a certain answer to a certain piece of code?
His conclusions are consistent with my understanding of the C standard. His justifications for his conclusions refer to specific rules regarding program behaviour, which suggests he's using the standard(s).
>First of all, this gives a strong indication that he's analyzing a compiler output, a compiler that he didn't reveal in the article.
He is using the output of some compiler to illustrate the potential consequences of making the given mistake. It doesn't really matter which; the point is that it is not legal to perform lvalue-to-rvalue conversion on the result of indirecting through a null pointer.
>could you or him point me to any page in the C99 standard document where it is explicitly stated along the lines that the compiler "should assume" the pointer to be not NULL after an undefined dereferencing in line (1) and hence ignore (2) and (3)?
No, because the C99 standard document does not say that. What it does say is effectively that the compiler MAY assume the pointer not to be null; more generally, the compiler is allowed to assume that the program never exhibits undefined behaviour.
- fizixer 12y ago> ... MAY assume ... and therefore his claim: > ... Turns out, bar() is invoked even when x is the null pointer ... is incorrect (bar may or may not be invoked) and misleading for C newbies, without any mention of the subtleties of standards and implementations. Hence my original comment.
- Dylan16807 12y agoYou're misreading a descriptive statement as normative. It could have been clearer but it's not wrong.