Range checking

From RAD Studio
Jump to: navigation, search

Go Up to Delphi Compiler Directives (List) Index

Type

Switch

Syntax

{$R+} or {$R-} {$RANGECHECKS ON} or {$RANGECHECKS OFF}

Default

{$R-} {$RANGECHECKS OFF}

Scope

Local

Remarks

The $R directive enables or disables the generation of range-checking code. In the {$R+} state, all array and string-indexing expressions are verified as being within the defined bounds, and all assignments to enumerated and subrange variables are checked to be within range. If a range check fails, an ERangeError exception is raised (or the program is terminated if exception handling is not enabled).

Enabling range checking slows down your program and makes it somewhat larger.