Package: gegl
Version: 1:0.4.72-2
Severity: important
Tags: patch
Forwarded: https://gitlab.gnome.org/GNOME/gegl/-/issues/480

Dear Maintainer,

gegl 1:0.4.72-2 fails to build from source on ppc64el when built with GCC 15
due to format_sensing test failure:

  ERROR: ../tests/simple/format-sensing.c:166:test_format_sensing:
  assertion failed: (babl_format_has_alpha (format))
  FAIL: tests/simple/format-sensing 1/1 FAIL 0.05s (exit status: 133 or signal 
5 SIGTRAP)

GCC 15 on ppc64el miscompiles the union-based bitwise sign-clearing helper 
(int_fabsf)
in operations/common/opacity.c, gegl/gegl-math.h, and 
gegl/buffer/gegl-sampler-cubic.c.
On ppc64el, the mask load is corrupted, causing int_fabsf(value - 1.0f) <= 
EPSILON
to evaluate to true for value = 0.5f. This bypasses the format conversion in
gegl:opacity and breaks format_sensing.

Replacing the union type-punning hacks with __builtin_fabsf / __builtin_fabs 
fixes
the issue and compiles directly to the hardware 'fabs' instruction on PowerPC.

Upstream issue: https://gitlab.gnome.org/GNOME/gegl/-/issues/480
Ubuntu tracking bug: https://bugs.launchpad.net/ubuntu/+source/gegl/+bug/2168951

Please find attached the patch.

Regards,
Viktor Pashaiev
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 <[email protected]>
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

Reply via email to