Yesterday I did:
>       (structptr_to_funcptr, funcptr_to_structptr): New functions/macros.
>       (xcopy_structptr): Renamed from xcopy_funcptr. Mark as inline.
>       (COPY_FUNCPTR, CODE): Use structptr_to_funcptr, funcptr_to_structptr.

This produces gcc -Wstrict-aliasing warnings on Linux/powerpc64. The fix is
to use an inline function instead of a macro.


2024-01-10  Bruno Haible  <br...@clisp.org>

        jit/cache tests: Avoid gcc -Wstrict-aliasing warning on Linux/powerpc64.
        * tests/jit/test-cache.c (funcptr_to_structptr): Turn into an inline
        function.

diff --git a/tests/jit/test-cache.c b/tests/jit/test-cache.c
index cad6d2a214..18416f8f51 100644
--- a/tests/jit/test-cache.c
+++ b/tests/jit/test-cache.c
@@ -124,7 +124,11 @@ funcptr_to_structptr (void * volatile funcptr)
 }
 # else
 #  define structptr_to_funcptr(p) ((void *) (p))
-#  define funcptr_to_structptr(funcptr) ((struct func *) (funcptr))
+static inline struct func *
+funcptr_to_structptr (void * volatile funcptr)
+{
+  return (struct func *) funcptr;
+}
 # endif
 static inline struct func *
 xcopy_structptr (struct func *structptr)




Reply via email to