An out-of-bounds access happens when a thread reads or writes beyond an array’s valid indices. If an array has five elements but eight threads try to access one element each, threads with indices 5, 6, and 7 access data that does not exist. section 2.12
Before doing the work, check that each thread’s index is below the element count: if (idx < n). Without this guard, a GPU program may fail, silently corrupt memory, or return incorrect results. NVIDIA’s compute-sanitizer can detect memory-access errors at runtime. section 2.12 section 3.16

