Catching array out of bounds
grauzone
none at example.net
Thu Nov 5 06:57:20 PST 2009
jicman wrote:
> grauzone Wrote:
>
>> Justin Johansson wrote:
>>> Also (and I' not 100% sure about this) that you might need to
>>> declare a variable along with the catch statement like as follows
>>> (at least that's what I always do regardless of whether or
>>> not it may be omitted) ...
>> And he should remember that out of bounds checking is enabled only in
>> debug builds. In release builds, out of bounds accesses will simply lead
>> to undefined behavior.
>
> Ok, I will bite... And why, then, it is in the array help as an option to catch the out of bounds?
I don't quite get what you're saying, but here's the bit of the
documentation that says that out of bounds checking is an optional
debugging feature:
"A program may not rely on array bounds checking happening"
http://www.digitalmars.com/d/1.0/arrays.html
You can try it yourself. Just compile the program with -release. No out
of bounds error will be thrown; instead the program may behave
abnormally or crash (or the error remains silent).
More information about the Digitalmars-d-learn
mailing list