Add WEBP_SELF_ASSIGN macro

WEBP_SELF_ASSIGN exists to clearly designate when a self-assignment is
intentional for the purposes of -fbounds-safety support. It also exists
to silence any compiler warnings that may exist when building without
-fboudnds-safety.

Sample showing behavior across the three major toolchains (clang, gcc,
msvc): https://godbolt.org/z/6r99dncW7

Change-Id: Ibbad5c0c3348dd6e2c4a70297b3e9cb6cf0d2817
This commit is contained in:
mxms
2025-08-14 00:16:24 +00:00
parent 2246828be3
commit 47a744d582

View File

@@ -110,4 +110,9 @@
#define WEBP_UNSAFE_FORGE_BIDI_INDEXABLE(typ, ptr, size) ((typ)(ptr)) #define WEBP_UNSAFE_FORGE_BIDI_INDEXABLE(typ, ptr, size) ((typ)(ptr))
#endif // WEBP_SUPPORT_FBOUNDS_SAFETY #endif // WEBP_SUPPORT_FBOUNDS_SAFETY
// This macro exists to indicate intentionality with self-assignments and
// silence -Wself-assign compiler warnings.
#define WEBP_SELF_ASSIGN(x) x = x
#endif // WEBP_UTILS_BOUNDS_SAFETY_H_ #endif // WEBP_UTILS_BOUNDS_SAFETY_H_