From 47a744d582c6515c91c0259b625d94aa5e0eaa5c Mon Sep 17 00:00:00 2001 From: mxms Date: Thu, 14 Aug 2025 00:16:24 +0000 Subject: [PATCH] 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 --- src/utils/bounds_safety.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/utils/bounds_safety.h b/src/utils/bounds_safety.h index 893cfab9..ccc89419 100644 --- a/src/utils/bounds_safety.h +++ b/src/utils/bounds_safety.h @@ -110,4 +110,9 @@ #define WEBP_UNSAFE_FORGE_BIDI_INDEXABLE(typ, ptr, size) ((typ)(ptr)) #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_