W1012 Constant expression violates subrange bounds
This message occurs if a conversion is made that was once legal but is now illegal, owing to the introduction of large unsigned types in Object Pascal after the Object Pascal 4 release.
var x: Integer; const y = Cardinal(MaxInt) + 1; begin x := y; Writeln(y); // writes 2147483648 Writeln(x); // writes -2147483648 end.
Before Cardinal was defined as an unsigned 32-bit integer (prior to Object Pascal 4), Cardinal was an unsigned 31-bit integer with range 0..MaxInt. Thus, every value in the range of Cardinal would fit in an Integer. After Object Pascal 4, Cardinal has the full unsigned 32-bit range of 0..$FFFFFFFF. The top half of its range is not convertible to an Integer; very high values of Cardinal (greater than MaxInt) will thus be converted into negative Integer numbers, according to the differences in how signed (two's complement) and unsigned integers are interpreted.