Re: Meaning of implementation def. behaviour (was: Re: C99 IDE for windows)
- From: santosh <santosh.k83@xxxxxxxxx>
- Date: Wed, 06 Aug 2008 22:03:53 +0530
Richard Heathfield wrote:
santosh said:
<snip>
3.4.4
1 unspecified behavior
use of an unspecified value, or other behavior where this
International Standard provides two or more possibilities and
imposes no further requirements on which is chosen in any instance
Okay, so let's take the classic example of unspecified behaviour -
order of evaluation. The Standard doesn't impose an ordering of any
kind, and therefore implicitly provides gazillions of possible
orderings. Implementations are free to do what they like, and don't
have to document it.
Hmm, so for this instance of unspecified behaviour the Standard omits
specifying directly one or more possibilities, and thus *all*
possibilities are implicitly specified, subject only to the constraints
and the syntax of the language. Okay, I think I get it.
3.4.1
1 implementation-defined behavior
unspecified behavior where each implementation documents how the
choice is made
By extension, here the Standard provides (possibly a subset of)
infinitely many possibilities, but requires the implementation to
document its choice. For example, for UINT_MAX the Standard requires
that it's an integer constant AND has a value that is at least 65535
AND (IIRC) is a power-of-two-less-one, but that still leaves
infinitely many possibilities.
So, in effect, an implementation must chose one particular value from a
set of values for UINT_MAX implicitly allowed by the Standard, by not
specifying one or more particular values, but simply a limit and some
related rules.
Implementations are perfectly free to
document this choice along lines such as "if the -foo switch is set,
UINT_MAX is 131071, otherwise if -bar is set it's 262143, otherwise
it's 37778931862957161709567".
Wouldn't that actually make them three different implementations, in
effect?
For iscntrl, implementations are free
to specify just about anything they like as a control character, and I
can find no prohibition on this choice being made dynamically, as long
as the rules are clearly specified (i.e. the implementation documents
how the choice is made).
But these rules themselves should remain constant for any single
invocation of the implementation. Is that right.
So by that reasoning, if I'm correct (and I don't think I am),
implementations can specify a "dynamic rule" or a set of such rules
whereby the value of the constants in limit.h can vary from one
instance of time to another, even within a single invocation of the
implementation (by which I'm including both the translation and
execution environment, and the execution of the program image too)? Is
this logic sound?
3.4
1 behavior
external appearance or action
Here "unspecified value" is not defined, as far as I can see. However
for each instance of unspecified behaviour it seems that the Standard
provides all possible courses of action and the implementation is
merely required to choose one course from this list,
But the Standard may, instead of providing all possible courses of
action, define a rule that places a constraint on the choice (or
several such rules). UINT_MAX is a good example of this. As long as
the implementation obeys those rules, it is free to use further rules
of its own, which need not be static ("the value is X") but could
instead be dynamic ("the value is a consequence of the application of
such-and-such rules with such-and-such parameters, subject to the
[normally minimal] limitations imposed by the Standard").
Okay. So unspecified behaviour essentially means that the Standard
either specifies N possibilities (where N >= 2), or specifies one or
more constraints (must they only be constraints?), which when applied
to the construct yield N possible behaviours?
But for each instance of unspecified behaviour, somehow or the other, N
forms of allowable courses of action must be derived, where N must be
two or more. Specifying just one form of behaviour (this then
becomes "defined") or not specifying any behaviour, either directly or
through constraints (undefined behaviour) is not allowed.
<snip>
In light of this interpretation (though I'm sure I've overlooked
something important somewhere),
I think you've overlooked the point that the range of possible
behaviours doesn't actually have to be written down anywhere in the
Standard for it to constitute a valid range. For example, the Standard
doesn't have to say: "The value of UINT_MAX shall be 65535 OR 131071
OR 262143 OR 524287 OR ... [snip infinitely many possibilities]..." -
and a good job too, or it would have to have infinitely many pages.
<snip>
But the forms of behaviour must be derivable, or otherwise, it would be
undefined.
So, in view of all this, how is one, as an implementor, to derive the
valid forms of behaviour for the implementation defined output for
the 'p' type specifier in printf? The final choice of the
implementation must be one from a set of 2 to N choices that the
Standard must specify literally or implicitly through it's constraints.
But what constraints can one apply to this case? Any ideas?
.
- Follow-Ups:
- Re: Meaning of implementation def. behaviour (was: Re: C99 IDE for windows)
- From: Richard Heathfield
- Re: Meaning of implementation def. behaviour (was: Re: C99 IDE for windows)
- From: Keith Thompson
- Re: Meaning of implementation def. behaviour (was: Re: C99 IDE for windows)
- References:
- Re: C99 IDE for windows
- From: arnuld
- Re: C99 IDE for windows
- From: CBFalconer
- Re: C99 IDE for windows
- From: arnuld
- Re: C99 IDE for windows
- From: Richard Heathfield
- Re: C99 IDE for windows
- From: arnuld
- Re: C99 IDE for windows
- From: Richard Heathfield
- Re: C99 IDE for windows
- From: arnuld
- Re: C99 IDE for windows
- From: Richard Heathfield
- Re: C99 IDE for windows
- From: arnuld
- Re: C99 IDE for windows
- From: santosh
- Re: C99 IDE for windows
- From: Richard Heathfield
- Re: C99 IDE for windows
- From: santosh
- Re: C99 IDE for windows
- From: Richard Heathfield
- Re: C99 IDE for windows
- From: santosh
- Re: C99 IDE for windows
- From: Richard Heathfield
- Re: C99 IDE for windows
- From: santosh
- Re: C99 IDE for windows
- From: Richard Heathfield
- Meaning of implementation def. behaviour (was: Re: C99 IDE for windows)
- From: santosh
- Re: Meaning of implementation def. behaviour (was: Re: C99 IDE for windows)
- From: Richard Heathfield
- Re: C99 IDE for windows
- Prev by Date: Re: C99 IDE for windows
- Next by Date: Re: C99 IDE for windows
- Previous by thread: Re: Meaning of implementation def. behaviour (was: Re: C99 IDE for windows)
- Next by thread: Re: Meaning of implementation def. behaviour (was: Re: C99 IDE for windows)
- Index(es):
Relevant Pages
|