Wojtek said:
Of course it could; the interesting question is whether it would have
to. When you say that a program "depends on undefined behaviour", are
you claiming that it's impossible to make the behaviour defined without
breaking the program (which is hard to agree with),
No.
or just that it's
possible to make the behaviour defined in a way that breaks the program
(which is trivially true)?
Didn't mean that either, but I fully agree. I'm getting a sense that
the lack of a temporal reference is part of the interpretation challenge.
Please don't say that you meant both, or
that the difference is insignificant.
Here you go using that ambiguous wording again. That's not helping.
There is a program. The program is real. The program includes
constructs which any C Standard familiar could reason as leading to
undefined behaviour during translation or execution via a conforming
implementation. Undefined behaviour is allowed. The program compiles.
The program works. The program does not work if these constructs are
removed. There is another such program. Real C programs depend on
undefined behaviour. Right now.
A real C programs doesn't rely on a complete lack of restrictions on the
implementation's behaviour.
Which is why there is no "only". "Real C programs only depend on..."
There's also no "all". "All real C programs only depend on..."
At most, it relies on a particular
behaviour on a particular implementation. If the behaviour matches what
the program expects, forbidding some of the *other* possible behaviours
is not going to break the program.
Sure.
No, thanks. I did not intend to comment on any other topics in this
thread, only the part that tried to clarify what you could have possibly
meant when you said that some programs "depend on undefined behaviour".
The suggestion to read the other posts can be independent of a choice to
comment on those other posts. Such perusal could contribute to a shared
context that my unintentionally challenging claim of agreement could be
associated with. It might be challenging simply due to the lack of a
shared context.
No, they depend on the fact that the C standard doesn't forbid *(char*)0
to access the first byte of memory.
Since it's been removed from my previous post, here's 'n1256.pdf'
section 3.4.3, point 1, again:
"undefined behavior
behavior, upon use of a nonportable or erroneous program construct or of
erroneous data, for which this International Standard imposes no
requirements"
I do not understand why this is different than what you have just said
above, starting with "No" in response to my claim that "They depend on UB."
Some other programs may depend on
the fact that attempting to access the first byte of memory results in a
signal being delivered to the program. But those programs don't depend
on the fact that the behaviour is undefined -- they just depend on the
fact that one or the other behaviour is allowed by the C standard (and
that it actually happens on a particulr implementation).
Please note that "the fact that the" B. is U. is not included in the
original, just as "only" is not included.
Regardless of that, I disagree. "The fact that one or the other
behaviour is allowed" seems very similar to "behavior...for which
this...Standard imposes no requirements", which is the definition for
undefined behaviour (as given above).
If the C
standard were changed to say that it's unspecified whether *(char*)0
accesses the first byte of memory or generates a signal, none of those
programs would suffer. In *that* sense, those programs do *not* rely on
undefined behaviour.
I'm not so sure about that. Is that an exhaustive list of the
possibilities? Is a list of two or more possibilities provided by the
Standard (unspecified) the same as a virtual infinitude of possibilities
(undefined)?
...
Well then I guess that's the problem. To me and apparently at least one
other person here, there's quite a big difference between those two
interpretations -- one is nonsensical and the other is quite easy to
agree with. That's why we're trying to understand which of them is
closer to what you intended to say. But if you refuse to give a clear
answer because you disagree that the difference is important, then the
discussion is not going to be easy.
There has been no refusal, but continued attempts to reach an
understanding instead, so please expect the same and please do not fret
about a potential refusal.
What are you talking about? Those are not three interpretations,
Hmm... If you read carefully, I did not say that there were three
interpretations in the quotation. I said "\"three\" subjects".
it's a
list of three cases. A reader interpreting only one or two of them
instead of all three is simply wrong.
How can I make this clear? "...if ___I___ say undefined behaviour, a
reader...has a fair interpretation..." That is, _me_. That is, take
the three subjects of the 4p2 quotation above and call them X,Y,Z. Now
take:
"Real C programs depend on the undefined behaviour of "dereferencing"
a null pointer constant cast to a complete object type under certain
circumstances."
What I have said was that a reader can interpret _my_ use of the words
"undefined behaviour" as any of X,Y,Z and that such an interpretation is
fair.
Hopefully put more simply: Use the C Standard to understand undefined
behaviour. If I say something about it, I fully intend my use of the
term to be interpreted according to the C Standard. If that means that
a statement of mine is ambiguous because the Standard offers multiple
choices, so be it. That's hardly my doing! (No intentional ambiguity.)
...
Did it meet with any disagreement, or was it just ignored? If it's any
consolation, I do agree that it sometimes is useful.
It did not meet with disagreement. The situation was no more and no
less than that it did not meet with any agreement (which has been
established as typical, thus far). And yes, that is a fantastic
consolation that someone else perceives a benefit for discussion ("Is
so!" "Is not!") if a distinction is made between these cases of undef.
behav. in the discussion. With a good sort of fortune, it could save
some time. So thanks very much!
Well no, unless again the interpretation(s) that you intended differ
from the one I assumed. I assumed you meant that it's impossible to get
rid of the undefined behaviour without breaking some programs, not that
it's possible to get rid of it in a way that breaks them. Or will you
say that that's not a difference worth being concerned about again?
Please allow me to re-post some original material:
Sure we can throw away the amended point #3, since we can agree that:
Real C programs depend on the undefined behaviour of "dereferencing"
a null pointer constant cast to a complete object type under certain
circumstances.
That is not meant as "it's impossible to get rid of the undefined
behavior without breaking some programs". It is directly in regards to
the proposal's amended point #3. If this is too vague, _perhaps_ we can
agree that:
One has a better chance of understanding some text by reading any
surrounding material to establish context.