RAD Studio (Common)
ContentsIndex
PreviousUpNext
Overflow checking (Delphi)
Type  
Switch  
Syntax  
{$Q+} or {$Q-} {$OVERFLOWCHECKS ON} or {$OVERFLOWCHECKS OFF}  
Default  
{$Q-} {$OVERFLOWCHECKS OFF}  
Scope  
Local  

Remarks 

The $Q directive controls the generation of overflow checking code. In the {$Q+} state, certain integer arithmetic operations (+, -, *, Abs, Sqr, Succ, Pred, Inc, and Dec) are checked for overflow. The code for each of these integer arithmetic operations is followed by additional code that verifies that the result is within the supported range. If an overflow check fails, an EIntOverflow exception is raised (or the program is terminated if exception handling is not enabled). 

The $Q switch is usually used in conjunction with the $R switch, which enables and disables the generation of range-checking code. Enabling overflow checking slows down your program and makes it somewhat larger, so use {$Q+} only for debugging.

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!