In some situations gnat fails to check range constraints of the type of a variable, allowing it to get a value out of the (supposed) allowed range too. Example: with ada.integer_text_io; use ada.integer_text_io; procedure miotest is n : integer := integer'last; begin while n > 0 loop n := n + 1; end loop; put(n); end miotest; ./miotest -2147483648 This should exit with CONSTRAINT_ERROR when it tries to do n := n + 1. Instead it returns -2147483648. The same appens with a variable of type natural, obtaining in the end a natural variable containing a negative integer. If n := n + 1 is tried without the loop, the compiler correctly warns that the CONSTRAINT_ERROR would be raised upon execution, as it happens: with ada.integer_text_io; use ada.integer_text_io; procedure miotest2 is n : integer := integer'last; begin n := n + 1; put(n); end miotest2; gnatmake miotest2 gnatgcc -c miotest2.adb miotest2.adb:9:16: warning: value not in range of type "Standard.Integer" miotest2.adb:9:16: warning: "Constraint_Error" will be raised at run time gnatbind -x miotest2.ali gnatlink miotest2.ali ./miotest2 raised CONSTRAINT_ERROR : miotest2.adb:9 range check failed emerge info Portage 2.0.50_pre20 (default-x86-1.4, gcc-3.3.2, glibc-2.3.3_pre20040117-r0, 2. 6.2-rc2) ================================================================= System uname: 2.6.2-rc2 i686 Intel(R) Pentium(R) 4 CPU 2.40GHz Gentoo Base System version 1.4.3.12 Autoconf: sys-devel/autoconf-2.59 Automake: sys-devel/automake-1.7.8 ACCEPT_KEYWORDS="x86 ~x86" AUTOCLEAN="yes" CFLAGS="-march=pentium4 -mfpmath=sse -Os -pipe" CHOST="i686-pc-linux-gnu" COMPILER="gcc3" CONFIG_PROTECT="/etc /usr/X11R6/lib/X11/xkb /usr/kde/2/share/config /usr/kde/3/s hare/config /usr/share/config /usr/share/texmf/dvipdfm/config/ /usr/share/texmf/ dvips/config/ /usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/c onfig/ /usr/share/texmf/xdvi/ /var/qmail/control" CONFIG_PROTECT_MASK="/etc/gconf /etc/env.d" CXXFLAGS="-march=pentium4 -mfpmath=sse -Os -pipe" DISTDIR="/usr/portage/distfiles" FEATURES="autoaddcvs ccache sandbox" GENTOO_MIRRORS="ftp://sunsite.cnlab-switch.ch/mirror/gentoo/ http://gentoo.orego nstate.edu http://www.ibiblio.org/pub/Linux/distributions/gentoo" MAKEOPTS="-j2" PKGDIR="/usr/portage/packages" PORTAGE_TMPDIR="/var/tmp" PORTDIR="/usr/portage" PORTDIR_OVERLAY="/usr/local/portage" SYNC="rsync://rsync.gentoo.org/gentoo-portage" USE="S3TC X aalib alsa apache2 avi caps cdr crypt cups dga dv dvb dvd encode foo maticdb gif gimpprint gpgme gpm gtk gtk2 imlib ipv6 java jpeg maildir mmx mozill a moznocompose moznoirc moznomail mpeg ncurses nls nptl oggvorbis opengl pam pdf lib perl plotutils png pnp python quicktime readline samba sasl sdl snmp sse ssl tcpd tetex tiff truetype usb wmf wxwindows x86 xchattext xml xml2 xmms xv zlib"
Sorry, I forgot the -gnato option, it seems to solve the problem. BTW I wonder why out of the loop it worked...