2.4. Checking for Stack Overflow

In Version 1.8, stack checks are included by default. To suppress all checks use the compiler option -gnatp. The stack limit, which is the lowest address in the stack, is held in global register %g7. Here is an example that overflows the 64K byte main program stack:

Example 2-8. Stack Overflow Check

$ more biggy.adb
procedure Biggy is
   S : String (1 .. 100_000);
begin
   null;
end Biggy;
$ leon-coff-gnatmake -g biggy
biggy.adb:2:04: warning: "S" is never assigned a value
leon-coff-gnatbind -x biggy.ali
leon-coff-gnatlink -g biggy.ali
$ leon-coff-run biggy
Unhandled trap at PC = 0x020012fc: 89 - Storage_Error
_ada_biggy():
.../biggy.adb:2