[fpc-pascal] Docs: portability differences between Borland/FPC

Martok listbox at martoks-place.de
Sun Aug 19 15:08:49 CEST 2018


Am 18.08.2018 um 23:25 schrieb Marco van de Voort:
> Summary: behaviour with range checks off is implementation defined?
No. "implementation different", but not really "implementation defined".

TP and Delphi are fully defined without range checks. In fact, TP is defined as
*having no runtime range checks at all* (TP7LG, Chapter 21), except for
Succ/Pred (and Inc/Dec by extension), which explicitly react to $R (TP7LG,
Chapter 4) . One might imagine:

  function Succ<T: Ordinal>(X: T): T; inline;
  begin
    Result:= T(Ord(X) + 1);
    {$IFOPT RANGECHECKS}
    if Result > High(T) then
      RuntimeError(201);
    {$ENDIF}
  end;

{Mentioned for completeness: method checks (our -CR) are also handled by $R}


ISO 7185 has mandatory range checks (as "dynamic violations"), but whether
adhering to a 30-year-old incredibly badly written standard that was obsolete at
publication (while at the same time implementing features of a far better
language) is a good idea I would seriously consider debatable.



But I don't actually want to debate that here, just collect information for users.





More information about the fpc-pascal mailing list