ambiguous ?

Henry Spencer henry at utzoo.uucp
Wed Oct 18 06:37:33 AEST 1989


In article <14089 at lanl.gov> jlg at lanl.gov (Jim Giles) writes:
>... 1) _Unspecified_ - the standard imposes no
>requirements at all; 2) _Undefined_ - The construct is illegal or
>non-portable, the standard imposes no requirements; 3) _Implementation_
>_defined_ - the behaviour is determined by the implementation.

A more accurate definition of _implementation_ _defined_ is that the
behavior is determined by the implementation *and must be documented*.
Otherwise it doesn't differ from _unspecified_ in any useful way.

>The order of evaluation of function arguments is _Unspecified_ not
>_Implementation_defined_.  This means that the evaluation order is
>allowed to vary EVEN WITHIN AN IMPLEMENTATION!  This is supposedly
>to allow optimization.

Yup.  Which it does.  (For example, in an argument list with expressions
of varying complexity, on a machine with few registers that wants to pass
arguments in registers, it is best to evaluate the complicated arguments
first so that the maximum number of registers are available for the job.)
This is the same, for much the same reasons, as letting subexpressions
of a single expression be evaluated in arbitrary order.  What's wrong
with it?

>... (this makes C the only
>ANSI language with deliberately undefined, as opposed to implementation
>defined, behaviour).

I could have sworn that a good many things were officially undefined in
Fortran (66 or 77, take your pick), such as the values of local variables
after return from a function.  I could be wrong -- I'm not a Fortran guru.
-- 
A bit of tolerance is worth a  |     Henry Spencer at U of Toronto Zoology
megabyte of flaming.           | uunet!attcan!utzoo!henry henry at zoo.toronto.edu



More information about the Comp.lang.c mailing list