ST || Array behavior

Hello everyone,

I’ve encountered some unexpected behavior while working with arrays in Automation Runtime.

When accessing an index outside of the declared array bounds, I don’t get any runtime error. Instead, the program reads the value from the next memory location. Moreover, it is also possible to write to that location.

From my understanding, I would expect either a bounds check or a runtime exception.

Is this the expected behavior in AR?Are there specific settings (e.g., compiler options, runtime checks) that control array bounds checking?

For context:

Language: Structured Text

Access method: direct indexing

Hello,

it is correct that the default Settings are not sending an Error when going out of Array bounds. It is mandatory that the Developer takes care of the Array Index to be inside of the bounds.

If you want to check your Applikation for Array Bound errors. You can use the IEC_CHECK - Library.

This library adds an automatic bounds check. But should not stary in the Application, becuase it inreases the load.

Greetings
Michael

While running the program, I was repeatedly encountering a seemingly random runtime error:

“Memory access violation occurred”

I now have a better idea of what to investigate first. Thanks for the guidance!

Hello,

You may have also a look here.

Greetings
Michael