Reputation: 16177
I have the following declaration of an anonymous subtype:
testConstraint : Integer Range -5 .. 5;
Then later, when assigning it:
testConstraint := -6;
Why am I not getting a Constraint_Error
?
Additional Details:
pragma suppress
statements in the code file in question (though there are some in files added via with
;gprbuild
using GPS 5.0.2 and GNAT Pro 6.4.2-gnatf -gnatp -gnat2012 -d
Upvotes: 1
Views: 552
Reputation: 6611
As @Timur and @theMayer notes:
-gnatp
suppresses all checks.
From the documentation:
-gnatp
This switch causes the unit to be compiled as though pragma Suppress (All_checks) had been present in the source. Validity checks are also eliminated (in other words -gnatp also implies -gnatVn). Use this switch to improve the performance of the code at the expense of safety in the presence of invalid data or program bugs.
Suppressing all checks is a really bad idea. You can do it for specific units, if you have proven that the checks aren't required (for example by using SPARK), and you have measured that suppressing all checks gives you a performance improvement which you need.
The solution is to use add the compiler flag -gnat-p
(and then - if the requirements are met - suppressing checks for individual files).
Upvotes: 6