comp.lang.ada
 help / color / mirror / Atom feed
* What does -gnato do?
@ 2006-08-26 22:52 Peter C. Chapin
  2006-08-27  1:51 ` Jeffrey R. Carter
  2006-08-27  8:55 ` Martin Krischik
  0 siblings, 2 replies; 7+ messages in thread
From: Peter C. Chapin @ 2006-08-26 22:52 UTC (permalink / raw)


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



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-09-05 23:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-26 22:52 What does -gnato do? Peter C. Chapin
2006-08-27  1:51 ` Jeffrey R. Carter
2006-08-27  8:55 ` Martin Krischik
2006-08-27 11:12   ` Peter C. Chapin
2006-08-28 11:49     ` Stephen Leake
2006-08-28 21:35       ` Jeffrey R. Carter
2006-09-05 23:37       ` Randy Brukardt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox