4 ms·
I agree with your points about undefined behavior. I'm pleasantly surprised that you didn't defend C's terrible strict aliasing rules. Your interpretation seem
by petergeoghegan 6y ago
I agree with your points about undefined behavior. I'm pleasantly surprised that you didn't defend C's terrible strict aliasing rules.
Your interpretation seems uncharitable. I imagine that you've interpreted the author's words literally, as somebody that has expert knowledge of compiler internals. Could the author really have meant to propose an "everything-can-randomly-change-anything pointers-are-integers" model?
- sanxiyn 6y agoWhat is the author's model then? I agree everything-can-randomly-change-anything interpretation is uncharitable, but then I am confused what the model is. (As you pointed out, that's the literal interpretation.) I think there is no model, and the author is just vaguely complaining they are not satisfied with status quo. But then the tone is unbelievably arrogant and deserves all the derision. By the way, I am of the opinion C's pointer model can be greatly improved to be programmer friendly, beyond getting rid of strict aliasing rule. For example, I think comparing two unrelated pointers (for sorting, lock ordering, etc.) should be well defined and not UB. But claiming "pointers are easy" is not the way to go.
- petergeoghegan 6y agoWhy would you assume that the author must have a formal model? It's a short blog post. Perhaps the author really is deserving of derision to some degree - who can say? It should not be based on a straw man that nobody could possibly believe, though.
- jcranmer 6y agoIn my experience, the model that most people railing against undefined behavior tend to end up proposing is a vague, "read-my-mind" sort of model. Semantics are hard, and undefined behavior makes it especially so. See the voluminous threads on llvm-dev trying to pin down what "undef" actually means for an example. In the context here, the linked article is a response to someone who is describing why defining a memory model is actually more difficult than it seems. The linked article is basically saying "screw that, it doesn't have to be hard, just use the obvious model" without specifying what the obvious model actually is. After you've been in a couple of hour-long meetings where everyone is arguing over what the "obvious" model actually says, it's painfully obvious that "obvious" isn't obvious.