What does -gnato do?



I'm using GNAT GPL 2006. In the User's Guide there is a description of
the -gnato option. This description includes the following example:

---> begin quote <---
X1 : Integer := Integer'Last;
X2 : Integer range 1 .. 5 := 5;
....
X1 := X1 + 1;
X2 := X2 + 1;

Here the first addition results in a value that is outside the base
range of Integer, and hence requires an overflow check for detection of
the constraint error. Thus the first assignment to X1 raises a
Constraint_Error exception only if `-gnato' is set.
---> end quote <---

Now consider the following program:

---> begin program <---
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Check is
X : Integer := Integer'Last;
begin
X := X + 1;
Put(X);
end Check;
---> end program <---

When I build this program *without* the -gnato option I get the
following warning:

C:\home\Languages\Ada>gnatmake check.adb
gcc -c check.adb
check.adb:6:11: warning: value not in range of type "Standard.Integer"
check.adb:6:11: warning: "Constraint_Error" will be raised at run time
gnatbind -x check.ali
gnatlink check.ali

And when I run the result I get

C:\home\Languages\Ada>check

raised CONSTRAINT_ERROR : check.adb:6 overflow check failed


So it seems that overflow checking is enabled even without -gnato
despite the fact that this contradicts the documentation. I conclude
that the default has changed and the documentation is out of date. Is
that true or am I misunderstanding something?

Note that when I include the -gnato option in the compilation of my
sample program the effect is the same. The -gnato option doesn't change
anything in this case.

Peter
.



Relevant Pages