Implementation-defined

Jim Gardner jagardner at watmath.waterloo.edu
Sat Dec 3 06:18:00 AEST 1988


[...]

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



More information about the Comp.std.c mailing list