Stephen.Clamage at Sun.COM
Sat Sep 16 09:21:25 PDT 2006
Not answering for Guillaume, but interjecting my own comments about
language in a standard:
George Corliss wrote:
> Let me paraphrase to see if I understand. What I hear you saying is that if
> we (the interval community), after due consideration, are unable to decide
> on the best way to handle a situation such as interval(double, NaN), that
> situation should be considered an erroneous program. The way a standard
> specifies "erroneous" is "undefined."
No, that is not correct. Some kinds of "erroneous" programs require
specific behavior from the C++ implementation (the combination of
compiler, linker, and runtime system).
The term "undefined behavior" applies to erroneous programs for which
the standard makes no requirements whatever.
> I had not thought of "undefined" that way before. I have thought of
> "undefined" as a license for the implementer to do whatever she wants,
> without even the obligation to tell me. I have considered "undefined" as
> weaker than "implementation-defined."
"Undefined" is weaker in terms of guarantees to the programmer.
"Undefined" means the programmer can have no expectations.
"Implementation-defined" means the programmer can consult the
documentation to determine what to expect.
"Undefined" is stronger in terms of warning flags in the specification.
"Undefined" means "no programmer should get into this situation."
"Implementation-defined" means "portability may be limited."
> Do you expect undefined situations to be flagged by compilers?
By definition, no check or warning is required for undefined
situtations. The C and C++ standards leave situations undefined if they
are in principle impossible to specify (e.g., isomorphic to the halting
problem), or if they are judged too expensive to require of every
implementation (e.g., detecting references to destroyed objects).
As I noted earlier, an implementation can choose to detect and act on
behavior that the standard says is undefined.
If you want a situation to be flagged by the C++ implementation, it
should be spelled out in the specification, or labeled
"implementation-defined", or possibly "unspecified" with a list of
Steve Clamage, stephen.clamage at sun.com
More information about the Std-interval