mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
Use src size for memcpy in order to avoid fortify complaints (#65222)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/65222 When compiling against the Android SDK with `--D_FORTIFY_SOURCE=2`, the compiler will complain that the `dst` size is a larger size than the `src` size due to the function templating using two differently sized objects. There is a `TORCH_CHECK` to ensure we don't go through with these `memcpy`'s, but in the interest of making the compiler happy, lets switch the `memcpy` to take `sizeof(src)`. Test Plan: CI Reviewed By: bertmaher, lanza Differential Revision: D30992678 fbshipit-source-id: b3e7aa992a3650e1051abad05be800b684e6332b
This commit is contained in:
parent
bfaaac6392
commit
c4ea447eb5
|
|
@ -103,7 +103,7 @@ template <typename To, typename From>
|
|||
To raw_bitcast(const From& src) {
|
||||
TORCH_CHECK(sizeof(To) == sizeof(From), "Invalid bitcast invocation");
|
||||
To storage;
|
||||
std::memcpy(&storage, &src, sizeof(From));
|
||||
std::memcpy(&storage, &src, sizeof(To));
|
||||
return reinterpret_cast<To&>(storage);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user