improve out-of-bounds checking with GCC 10 attribute access [BZ #25219]