summaryrefslogtreecommitdiffstats
path: root/src/common/bit_field.h
diff options
context:
space:
mode:
authorLiam <byteslice@airmail.cc>2022-07-10 02:33:03 +0200
committerLiam <byteslice@airmail.cc>2022-07-10 04:43:45 +0200
commita1c1ad096d23d76de2924ce299ecd49e66674e77 (patch)
tree2da5d6548a80d05831010160182d07a2f6546aa2 /src/common/bit_field.h
parentMerge pull request #8501 from liamwhite/backtrace-again (diff)
downloadyuzu-a1c1ad096d23d76de2924ce299ecd49e66674e77.tar
yuzu-a1c1ad096d23d76de2924ce299ecd49e66674e77.tar.gz
yuzu-a1c1ad096d23d76de2924ce299ecd49e66674e77.tar.bz2
yuzu-a1c1ad096d23d76de2924ce299ecd49e66674e77.tar.lz
yuzu-a1c1ad096d23d76de2924ce299ecd49e66674e77.tar.xz
yuzu-a1c1ad096d23d76de2924ce299ecd49e66674e77.tar.zst
yuzu-a1c1ad096d23d76de2924ce299ecd49e66674e77.zip
Diffstat (limited to 'src/common/bit_field.h')
-rw-r--r--src/common/bit_field.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/common/bit_field.h b/src/common/bit_field.h
index 16d805694..7e1df62b1 100644
--- a/src/common/bit_field.h
+++ b/src/common/bit_field.h
@@ -146,7 +146,16 @@ public:
}
constexpr void Assign(const T& value) {
+#ifdef _MSC_VER
storage = static_cast<StorageType>((storage & ~mask) | FormatValue(value));
+#else
+ // Explicitly reload with memcpy to avoid compiler aliasing quirks
+ // regarding optimization: GCC/Clang clobber chained stores to
+ // different bitfields in the same struct with the last value.
+ StorageTypeWithEndian storage_;
+ std::memcpy(&storage_, &storage, sizeof(storage_));
+ storage = static_cast<StorageType>((storage_ & ~mask) | FormatValue(value));
+#endif
}
[[nodiscard]] constexpr T Value() const {