https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110514
Bug ID: 110514 Summary: d: accesses immutable arrays using constant index still bounds checked Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: d Assignee: ibuclaw at gdcproject dot org Reporter: ibuclaw at gcc dot gnu.org Target Milestone: --- For example: --- immutable uint[] arr = [1,2,3]; void test() { immutable uint* p = arr.ptr; if (arr[0]== p[0] && arr[1] == p[1] && arr[2] == p[2]) return; assert(0); } --- Although the size and value of `arr` is known at compile-time, and is guaranteed to never change at run-time, there are still three calls to `_d_arrayboundsp` inserted into the program.