diff mbox series

[FFmpeg-devel,v2] intreadwrite: Indicate potential aliasing in AV_RN/AV_WN for Clang/MSVC mode

Message ID 20230804112856.3896010-1-martin@martin.st
State Accepted
Commit 62fac040c83bea33d43bbc98d6f11189b058d097
Headers show
Series [FFmpeg-devel,v2] intreadwrite: Indicate potential aliasing in AV_RN/AV_WN for Clang/MSVC mode | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Martin Storsjö Aug. 4, 2023, 11:28 a.m. UTC
Use the GCC specific codepath for Clang in MSVC mode too.
This matches the condition used in a number of other places.

MSVC doesn't have a way to signal potential aliasing, while GCC
(and Clang) can use __attribute__((may_alias)) for this purpose.

When building with Clang in MSVC mode, __GNUC__ isn't defined but
_MSC_VER is as Clang primarily impersonates MSVC - but even then it
does support the GCC style attributes.

The GCC specific codepath uses av_alias, which expands to
the may_alias attribute if supported. The MSVC specific codepath
doesn't use av_alias so far (as MSVC doesn't support any
corresponding attribute).

This fixes a couple HEVC decoder tests when built with Clang 14 or
newer in MSVC mode (with issues observed on all of x86_64, armv7
and aarch64).
---
v2: Changed to just use the GCC specific codepath here, as suggested
by Andreas on irc.

Will push if there's no objections.
---
 libavutil/intreadwrite.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavutil/intreadwrite.h b/libavutil/intreadwrite.h
index c4679fdba4..21df7887f3 100644
--- a/libavutil/intreadwrite.h
+++ b/libavutil/intreadwrite.h
@@ -213,7 +213,7 @@  typedef union {
  * by per-arch headers.
  */
 
-#if defined(__GNUC__)
+#if defined(__GNUC__) || defined(__clang__)
 
 union unaligned_64 { uint64_t l; } __attribute__((packed)) av_alias;
 union unaligned_32 { uint32_t l; } __attribute__((packed)) av_alias;