[comp.std.c] Implementation-defined

jagardner@watmath.waterloo.edu (Jim Gardner) (12/03/88)

[...]

The important point about the term "implementation-defined"
is that it applies to *behavior*.  It is used in connection
with code whose syntax and use is correct, but whose behavior
can vary from machine to machine.  A good example would be
integer division with one negative value, as in

	(-9)/5

Of course, this is a perfectly good C expression, but
implementations are allowed to choose either -1 or -2
as the result.  In other words, the behavior will vary
from system to system.

In the above case, there are only two accepted behaviors
(truncating towards zero or minus infinity).  In other cases,
there is a wide range of behavior possible.  The standard says
that when something has implementation-defined behavior, the
behavior must be documented.

The standard also says that constructs with implementation-defined
behavior are correct...which means that the implementation is required
to accept them.  The implementation is still free to output warnings
to its heart's content; the standard puts no restrictions on issuing
warnings.

		Jim Gardner, University of Waterloo

bill@twwells.uucp (T. William Wells) (12/05/88)

In article <22536@watmath.waterloo.edu> jagardner@watmath.waterloo.edu (Jim Gardner) writes:
: The important point about the term "implementation-defined"
: is that it applies to *behavior*.  It is used in connection
: with code whose syntax and use is correct, but whose behavior
: can vary from machine to machine.

Right. But the point I'm making is that there are things in the
standard which are called "implementation defined" which *determine*
what use is correct, e.g.,

	int     x;
	enum foo x;

Whether using `enum foo' is correct or not depends on something
implementation defined: which type enum foo is compatible with.  The
problem seems to stem from the fact that "implementation defined" is
of behavior, but the use in this case is of semantics.

Again, I believe that the stated definition of "implementation
defined" is incomplete; the standard frequently labels things to be
implementation defined which are not behaviors.  And for those
things, the restrictions on "implementation defined", that the
construct in question be correct and that the implementation be
required to accept it, do not apply.

---
Bill
{uunet|novavax}!proxftl!twwells!bill