autoconf: Varieties of Unportability
1
1 13.1 Varieties of Unportability
1 ===============================
1
1 Autoconf tests and ordinary programs often need to test what is allowed
1 on a system, and therefore they may need to deliberately exceed the
1 boundaries of what the standards allow, if only to see whether an
1 optional feature is present. When you write such a program, you should
1 keep in mind the difference between constraints, unspecified behavior,
1 and undefined behavior.
1
1 In C, a "constraint" is a rule that the compiler must enforce. An
1 example constraint is that C programs must not declare a bit-field with
1 negative width. Tests can therefore reliably assume that programs with
1 negative-width bit-fields are rejected by a compiler that conforms to
1 the standard.
1
1 "Unspecified behavior" is valid behavior, where the standard allows
1 multiple possibilities. For example, the order of evaluation of
1 function arguments is unspecified. Some unspecified behavior is
1 "implementation-defined", i.e., documented by the implementation, but
1 since Autoconf tests cannot read the documentation they cannot
1 distinguish between implementation-defined and other unspecified
1 behavior. It is common for Autoconf tests to probe implementations to
1 determine otherwise-unspecified behavior.
1
1 "Undefined behavior" is invalid behavior, where the standard allows
1 the implementation to do anything it pleases. For example,
1 dereferencing a null pointer leads to undefined behavior. If possible,
1 test programs should avoid undefined behavior, since a program with
1 undefined behavior might succeed on a test that should fail.
1
1 The above rules apply to programs that are intended to conform to the
1 standard. However, strictly-conforming programs are quite rare, since
1 the standards are so limiting. A major goal of Autoconf is to support
1 programs that use implementation features not described by the standard,
1 and it is fairly common for test programs to violate the above rules, if
1 the programs work well enough in practice.
1