Description: Use compiler builtins for absolute float/double in gegl-math and opacity
 Replace union bitwise float sign-bit clearing hacks with __builtin_fabsf
 and __builtin_fabs. The union type-punning hack is miscompiled by GCC 15 on
 ppc64el, resulting in format_sensing test failures in gegl:opacity.
Author: Viktor Pashaiev <w.paszajew@gmail.com>
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/gegl/+bug/2168951
Forwarded: https://gitlab.gnome.org/GNOME/gegl/-/issues/480
Last-Update: 2026-10-12

--- a/gegl/gegl-math.h
+++ b/gegl/gegl-math.h
@@ -25,22 +25,12 @@
 
 static inline float gegl_fabsf (float x)
 {
-  union {
-   float f;
-   guint32 i;
-  } u = {x};
-  u.i &= 0x7fffffff;
-  return u.f;
+  return __builtin_fabsf (x);
 }
 
 static inline double gegl_fabs (double x)
 {
-  union {
-   double d;
-   guint64 i;
-  } u = {x};
-  u.i &= 0x7fffffffffffffff;
-  return u.d;
+  return __builtin_fabs (x);
 }
 
 static inline float gegl_floorf (float x)
--- a/operations/common/opacity.c
+++ b/operations/common/opacity.c
@@ -56,9 +56,7 @@
 
 static inline gfloat int_fabsf (const gfloat x)
 {
-  union {gfloat f; guint32 i;} u = {x};
-  u.i &= 0x7fffffff;
-  return u.f;
+  return __builtin_fabsf (x);
 }
 
 static void
--- a/gegl/buffer/gegl-sampler-cubic.c
+++ b/gegl/buffer/gegl-sampler-cubic.c
@@ -283,9 +283,7 @@
 
 static inline gfloat int_fabsf (const gfloat x)
 {
-  union {gfloat f; guint32 i;} u = {x};
-  u.i &= 0x7fffffff;
-  return u.f;
+  return __builtin_fabsf (x);
 }
 
 static inline gfloat
