{$ extended-pascal} {gpc version 20050331, based on gcc-3.2.3 (mingw special 20030504-1)} program SuccPred (input, output); {ISO 6.7.6.3 (pg. 78 succ(x, k) x shall be of an ordinal-type k shall be of integer-type ... It shall be an error if such a value does not exist. succ(x) Shall be equivalent to succ(x, 1) pred(x) Shall be equivalent to succ(x, -1) }
var b: boolean value false;
begin writeln('succ(b, 2) = ', Succ(b, 2) ); {must be error!} writeln('Pred(b) = ', Pred(b)); {must be error!}
{The next sentence is an error ISO 6.4.2.2 a.1 pg 24 All integral values in the closed interval from -maxint to +maxint shall be values of the integer-type.} {So... pred(-maxint) is not of the integer-type. There must be another out of range error!} writeln('pred(-maxint) = ', pred(-maxint));
{With the next sentence the compiler say 'arithmetical overflow' perhaps should say 'out of range'} writeln('succ( maxchar ) = ', succ( maxchar ) ); end.