Felipe Monteiro de Carvalho wrote on Wed, 10 Feb 2016:
Why does this trigger an range check exception: var lNum: Cardinal; lStr: string; begin lNum := High(Cardinal); lStr := Format('Num=%u', [lNum]); Format doesn't support integer numbers above High(Integer) ?
Array of const supports longint, int64 and qword, but no cardinal (Delphi compatibility, and adding it would also mean that all callee side code for array of const would have to be adapted to deal with vtCardinal). Cardinal is passed as longint and not as int64, again for Delphi compatibility and because existing code may behave unexpectedly should this be changed.
In Delphi modes, for Delphi compatibility, we don't perform range checking when passing a cardinal to an array of const. In FPC modes, we do.
I really need to use IntToStr?
That, or typecast the cardinal either to longint or int64, or locally disable range checking.
Jonas _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal