Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't use vector accessor methods to do pointer math; unblock platfor…
…m010 (pytorch#73414) Summary: Pull Request resolved: pytorch#73414 The code here previously used this creative pointer math ``` const auto end = reinterpret_cast<uintptr_t>(&managed_tensor_storage_impls_.at(managed_tensor_storage_impls_.size())); ``` This has the form ``` const auto end = &A[N]; ``` this works just fine if `A` is C-style array since `&A[N]` can get transformed to `(A+N)` where `A` is a simple pointer without ever dereferencing. But this is C++ and `A` is a vector, so `A[N]` calls the accessor method, reaches into an illegal place in memory, and then we get the address of that. (Or so I deduce.) We sidestep the issue by using `data()` to get the desired memory address directly. Test Plan: Sandcastle Reviewed By: meyering Differential Revision: D34468166 fbshipit-source-id: d1bcbdceddd7c1da8204f90a446793945ebe9a34 (cherry picked from commit e93cc37)
- Loading branch information