Probably 12 posts back from this one I'm typing now; sorry.
In how many posts must I substitute "unexpected
behaviour" for "undefined behaviour" in order to determine your meaning?
5 of mine; sorry.
Have you said what "unexpected behaviour" is?
Not explicitly, no. I thought it would be obvious that it was the
context of a Windows debugger notifying the programmer, since Geoff had
just discussed that.
Does it depend on who is
doing the expecting?
Not really. If the program operates as expected without the debugger
interrupting, that's probably commonly desired by different programmers.
Does any meaning survive after addressing these
questions?
Yes, I think so. Having seen these answers, do you?
But you seem to make the same mistake when explicitly using C's terms
and without any of the "unexpected/undefined" madness above. E.g.:
| For example, if a free'd pointer becomes 0x0000000C, in C terminology,
| it'd be an "indeterminate value." But, using C terminology again,
| it'd be an "unspecified value" rather than a "trap representation", as
| the value can be read and passed around.
This suggest that you think it can't be a trap representation because it
can be read and passed around. A trap representation is nothing more
than a representation that does not denote a valid value for the type
in question. The effect of using it can be entirely benign.
I'm sorry you interpreted it that way. Would it be best to surround
every paragraph of every response with context, to prevent
misunderstanding? In that quote, I thought it was obvious that this was
in the context of using a Microsoft debugger, where the behaviour would
agree with the semantics of an "unspecified value"; not warning the
programmer during a read of the value (which it _could_).
In the summary below, I hope it's clear that a recurring theme was to
establish 0x0000000C as some kind of a trap value, so the quote above
doesn't match with that without deciding that it needs additional context.
Here's a summary of how the conversation has gone, from my perspective.
All quotes are fictional, and names have been omitted:
Me: "If an uninitialized 'unsigned char' can have a trap representation,
then...[something]"
A: "Whatever it has isn't a trap representation, you idiot. It might
not even have a value."
Me: "Why wouldn't it have a value? Is it because it might not
successfully translate? Ok, what about in this code example where it
does translate?"
B: "What would you say it has?"
Me: "An [C] indeterminate value and a magic property \"uninitialized\".
Here's some history, since you asked what I would say..."
B: "Here are Microsoft's documented [non-C] trap values..."
Me: "Nice summary! Say, isn't there another one, 0x0000000C, as a
[non-C] trap for [non-C] null pointers? I don't remember..."
C: "Oh no, that wouldn't be a [C] null pointer."
Me: "Yes, well I was talking about B's [non-C] trap values. I see a
Microsoft debugger catch these things and call them [non-C] null pointers."
C: "A [C] null pointer isn't a [C] trap representation. Does this thing
behave like a [C] null pointer?"
Me (intended): "Well it only behaves badly upon dereferencing."
C: "If it's not a [C] null pointer, then it shouldn't be called one, and
it's off-topic."
D: "There could be multiple [C] null pointer representations."
Me (missing C's cue to drop it): "That could be. Maybe the bits have
something to do with useful debug-info, such as a 'free'd pointer."
C: "That seems unlikely, due to pass-by-value. We're still not talking
about [C] null pointers if it doesn't behave like a [C] null pointer."
Me: "Agreed; it doesn't match. So what's the closest thing,
behaviour-wise? It seems like a [C] null pointer, in some ways."
C: "It could be closest to a [C] trap representation. It seems pretty
straight-forward."
Me (intended): "Well for those who observe 0x0000000C in a Microsoft
debugger, the program behaves well until it's dereferenced, so it's not
closest to a [C] trap representation, but to a [C] null pointer."
You: "It could be closest to a [C] trap representation. And don't say
\"undefined behavour\" if you don't mean it."
Me: "Oops. True."
And agreed again; we all [ought to] know:
All behaviours are consistent with UB.
Thankfully, 3 people have now made it abundantly clear that comparing
C terminology to subjects outside of C is not going to be fruitful.
Are you not using C's terms in the quote above?
Yes I was, but it only makes for confusion, so I'll try to avoid that.