https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123703

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Doesn't have to be anonymous union, e.g.
struct S { int a; };
struct S abs (int);

int
bar (int j)
{
  return abs (j);
}
ICEs too (and started to ICE before r0-71179 so I can't bisect).

I'd go with
2026-01-22  Jakub Jelinek  <[email protected]>

        PR middle-end/123703
        * builtins.cc (fold_builtin_abs): Return NULL_TREE if type is not
        integral.

        * gcc.c-torture/compile/pr123703.c: New test.

--- gcc/builtins.cc.jj  2026-01-02 09:56:09.907340908 +0100
+++ gcc/builtins.cc     2026-01-22 11:20:57.607868166 +0100
@@ -9538,7 +9538,7 @@ fold_builtin_fabs (location_t loc, tree
 static tree
 fold_builtin_abs (location_t loc, tree arg, tree type)
 {
-  if (!validate_arg (arg, INTEGER_TYPE))
+  if (!validate_arg (arg, INTEGER_TYPE) || !INTEGRAL_TYPE_P (type))
     return NULL_TREE;

   if (TYPE_UNSIGNED (type))
--- gcc/testsuite/gcc.c-torture/compile/pr123703.c.jj   2026-01-22
11:22:20.733473067 +0100
+++ gcc/testsuite/gcc.c-torture/compile/pr123703.c      2026-01-22
11:23:34.705231596 +0100
@@ -0,0 +1,10 @@
+/* PR middle-end/123703 */
+
+struct S { int a; };
+struct S abs (int);
+
+struct S
+bar (int j)
+{
+  return abs (j);
+}

Reply via email to