How can I detect out-of-bounds accesses (static) for arrays?

The option -Warray-bounds is set by default and will issue a warning if it is triggered.

Using this option does not provide a runtime check. The bounds and accesses have to be known in the compile time, which is not a typical case.