Yet another strike against the current AA implementation
bearophile
bearophileHUGS at lycos.com
Wed Apr 29 08:29:02 PDT 2009
Andrei Alexandrescu:
> [Detecting stack overflow at runtime] In a way it is trivial... if you accept a 7% added overhead per function call :o). (The number is what I remember costed Borland Pascal.)<
Now Delphi and FreePascal allow to switch that on and off. From the page:
http://www.freepascal.org/docs-html/prog/progsu100.html
1.2.24 $S : Stack checking
The {$S+} directive tells the compiler to generate stack checking code. This generates code to check if a stack overflow occurred, i.e. to see whether the stack has grown beyond its maximally allowed size. If the stack grows beyond the maximum size, then a run-time error is generated, and the program will exit with exit code 202.
Specifying {$S-} will turn generation of stack-checking code off.
The command line compiler switch -Ct has the same effect as the {$S+} directive.
By default, no stack checking is performed.
I have never timed programs to test how much you have to pay if you want stack checking code. The compiler is free, and suitable testing programs can be found in the Shootout site, so if you want you don't need much time to test this.
Bye,
bearophile
More information about the Digitalmars-d
mailing list