[PATCH] D64281: [Object] Create MutableELFObject Class for Doing Mutations on ELFObjectFiles [Part 1]

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 22 03:50:30 PDT 2019


jhenderson added a comment.

In D64281#1640474 <https://reviews.llvm.org/D64281#1640474>, @abrachet wrote:

> I've been thinking about this, is `size_t` safe to use? Some methods from inherited classes use `uint64_t` on my machine its fine because even `unsigned long` and `unsigned long long` have the same width and sign but on a 32 bit machine I think that assigning to a `size_t` (which is guaranteed to be word size, I think) from a `uint64_t` might produce a warning. I don't think there are any examples in this patch, but this seemed like the best place to ask.


You should use size_t and consider casting for cases using uint64_t. In a 32-bit build, size_t is usually a 32-bit number (i.e. `unsigned int`), so theoretically, the compiler could produce warnings for truncation issues when converting from a uint64_t. Since the main thing these indexes are used for is for accessing a vector, the type should match the argument type of `std::vector<T>::operator[]`, which is (usually) a `size_t`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64281/new/

https://reviews.llvm.org/D64281





More information about the llvm-commits mailing list