Controlling Run-Time Checks (GNAT User’s Guide for Native Platforms)

#### 6.3.1.1 Controlling Run-Time Checks ¶

By default, GNAT generates all run-time checks, except stack overflow checks and checks for access before elaboration on subprogram calls. The latter are not required in default mode because all necessary checking is done at compile time.

The GNAT switch, `-gnatp` allows you to modify this default; see Run-Time Checks.

Our experience is that the default is suitable for most development purposes.

Elaboration checks are off by default and also not needed by default since GNAT uses a static elaboration analysis approach that avoids the need for run-time checking. This manual contains a full chapter discussing the issue of elaboration checks and you should read this chapter if the default is not satisfactory for your use,

For validity checks, the minimal checks required by the Ada Reference Manual (for case statements and assignments to array elements) are enabled by default. You can suppress these by using the `-gnatVn` switch. Note that in Ada 83, there were no validity checks, so if the Ada 83 mode is acceptable (or when comparing GNAT performance with an Ada 83 compiler), it may be reasonable to routinely use `-gnatVn`. Validity checks are also suppressed entirely if you use `-gnatp`.

Note that the setting of the switches controls the default setting of the checks. You may modify them using either `pragma Suppress` (to remove checks) or `pragma Unsuppress` (to add back suppressed checks) in your program source.