PR #24244 opened by Kacper Michajłow (kasper93)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24244
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24244.patch

Clang reports itself as gcc 4.2, so av_alloc_size was never applied for
it, and neither attribute was applied for clang with MSVC target, where
__GNUC__ is not defined.


From 6580390717b103ad62c340939ad6e20b27d875f6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= <[email protected]>
Date: Sat, 22 Aug 2026 19:05:52 +0200
Subject: [PATCH] avutil/mem: enable allocation attributes for clang
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Clang reports itself as gcc 4.2, so av_alloc_size was never applied for
it, and neither attribute was applied for clang with MSVC target, where
__GNUC__ is not defined.

Signed-off-by: Kacper Michajłow <[email protected]>
---
 libavutil/mem.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavutil/mem.h b/libavutil/mem.h
index ab7648ac57..e305f2c201 100644
--- a/libavutil/mem.h
+++ b/libavutil/mem.h
@@ -65,7 +65,7 @@
  * @see <a 
href="https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-g_t_0040code_007bmalloc_007d-function-attribute-3251";>Function
 attribute `malloc` in GCC's documentation</a>
  */
 
-#if AV_GCC_VERSION_AT_LEAST(3,1)
+#if AV_GCC_VERSION_AT_LEAST(3,1) || defined(__clang__)
     #define av_malloc_attrib __attribute__((__malloc__))
 #else
     #define av_malloc_attrib
@@ -86,7 +86,7 @@
  * @see <a 
href="https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-g_t_0040code_007balloc_005fsize_007d-function-attribute-3220";>Function
 attribute `alloc_size` in GCC's documentation</a>
  */
 
-#if AV_GCC_VERSION_AT_LEAST(4,3)
+#if AV_GCC_VERSION_AT_LEAST(4,3) || defined(__clang__)
     #define av_alloc_size(...) __attribute__((alloc_size(__VA_ARGS__)))
 #else
     #define av_alloc_size(...)
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to