Rainer said:
The text was "There is no such thing as a form of undefined behaviour
because it is undefined." And it was written in response to your claim
that the standard would specify 'forms of the undefined', in other
words impose, requirements on it.
The Standard specifies no such thing as "forms of the undefined",
and no one here is specifying such things, either. Rather, they
are giving examples of behavior which do not contradict UB in the
Standard.
No one is saying "i = i++;" _will_ do such-and-such. Rather, they
are saying that "i = i++;" _may_ do such-and-such, and it would
still be conforming.
[...]
The issue is perfectly clear.
That
i = 3;
i = ++i;
means 'the value of i is now 3' is wrong,
No, it's not. Or, rather, it might not. It is certainly possible
that a given implementation results in i having a value of 3, and
such an implementation would be conforming.
Now, to say that "the value of i shall be 3" would be wrong, as it
contradicts the Standard. (Unless you are an implementor, and you
have chosen to define your particular implementation's behavior in
this case. Defining what your implementation does with UB is
allowed.)
because the meaning of this statement is undefined.
I assume that "this statement" refers to "i = ++i;" and not "the
value of i is now 3".
'i has now the value of 4' is wrong for the
same reason.
Again, the value of i may be 4 in a conforming implementation.
Stating that it means that 'the front door should open'
is still wrong.
No one here is making such a statement. There is a world of
difference between "the front door should open" and "the front
door could open".
And, again, if you are making your own implementation, you are
certainly free to say "the front door should open" as it
pertains to your implementation.
Same reason again. And this can be continued for every
possible statement about anything: There is no statement which is
supposed to be true, provided the reference for determining what
exactly is true or false is the C-standard, which, for this particular
instance, does not define that.
Every statement made here by the regulars is true in this
regard, as they are always qualified with "may do this", or "does
this on my particular platform".
This is completely orthogonal to the question what conceivable
behaviour of C-implementations when processing this piece of non-C
could be. And C is again very simple in this respect: Whatever the
behaviour may be, it does not matter. No reason to discuss it.
There are plenty of reasons to discuss this when the subject comes
up with someone posting either a question ("why does X do Y?") or,
even more importantly, when someone answers "why" with a definitive
statement ("because 'i++' returns the old value").
The reason for discussing it is to make it clear to the reader that
UB has been invoked, and the result of UB can be, literally, anything.
--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody |
www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net |
www.fptech.com | <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:ThisIsASpamTrap@gmail.com>