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 |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access