julia
0029162a - reinterpretarray: Use aligned_sizeof for elsize when element sizes match (#62544)

Commit
29 days ago
reinterpretarray: Use aligned_sizeof for elsize when element sizes match (#62544) When `sizeof(T) == sizeof(S)`, a `ReinterpretArray` maps elements 1-to-1 to the parent array, so the memory stride between consecutive elements should be `aligned_sizeof(S)` (the parent's storage stride), matching how `Array` uses `aligned_sizeof` for `elsize` (changed in commit 58a8c4ae00, which fixed #26026). Previously `elsize` returned `sizeof(T)` for all `ReinterpretArray`s, which gave the wrong stride for non-power-of-2 primitive types (e.g., `sizeof(Int24) = 3` but `aligned_sizeof(Int24) = 4`). Also update `_getindex_ptr` and `_setindex_ptr!` to use `aligned_sizeof(T)` for pointer offset computation, so the pointer path agrees with the correct stride. Fixes #62398 This pull request was written with the reference of generative AI and researched through the webpages reference. Co-authored-by: opencode[bot] <162913842+opencode[bot]@users.noreply.github.com>
Author
Parents
Loading