pragma boundschecking

Xojo 2019r2 / Win 10

Why does following code throw a OutOfBoundsException, instead of hard crash?

dim i() as integer

#pragma boundschecking false

dim x as integer = i(0)

I assume this calls an array getter function, which does the bound check always.

The pragma can only work if the Xojo compiler inlines the lookup via pointer operations.

Does that mean that #pragma boundschecking false never makes any difference?

you may need to ask someone from Xojo Inc. who can look into the compiler.

What happens when you put the pragma as the first line?

I’m pretty sure I was told by one of the Joes that this is basically a no-op now.

A few years ago we moved some code from RB to Xojo. The RB version worked fine but the Xojo version triggered an OutOfBoundsException. It turned out the RB version should have triggered the exception but was being masked by the pragma and by chance wasn’t crashing altogether.

Ah ok - that makes sense.