Name
$OverflowChecks Compiler Directive
Syntax
{$Q-} // default {$OverflowChecks Off} // default {$Q+} {$OverflowChecks On}
Scope
Local
Description
The $OverflowChecks
directive tells the compiler to
generate code that checks the result of integer and enumerated
operations to ensure the results are within the bounds of the integer
or enumerated type. If an operation produces an out-of-range result,
Delphi reports runtime error 5 (EIntOverflow
).
Tips and Tricks
You should always enable the
$OverflowChecks
directive because it can catch
numerous errors in your code. A common misconception is that the
checks should be disabled in released programs. If an integer or
enumerated overflow occurs, you want to catch the error as soon as
possible, and not wait for the error to propagate in unknown and
unpredictable ways through your program, possibly corrupting your
user’s data along the way. Do not disable the overflow checks
unless you have a specific performance problem, and then disable the
checks only in the performance-critical parts of your code.
See Also
$RangeChecks Compiler Directive |
Get Delphi in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.