]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
factor: use 1-word code only when tested
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 23 Jun 2025 17:26:28 +0000 (10:26 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 10 Jul 2025 00:12:40 +0000 (17:12 -0700)
* src/factor.c (print_factors): Use single-precision code only
when word size is 32 or 64, as it isn't tested for other sizes and
is known to not work when it the size is 128.  This change does
not affect any known practical platforms.

src/factor.c

index 9ccc755d79aad7b8982deb61d14f273b6f0a3e77..641fbcaff5d9edcf235ebdf0810f727618fe5171 100644 (file)
@@ -2308,8 +2308,16 @@ print_factors (char const *input)
 
   switch (err)
     {
-    case LONGINT_OK:
-      if (hi (u) >> (W_TYPE_SIZE - 1) == 0)
+    case LONGINT_OK:;
+      /* Use single-precision code only when W_TYPE_SIZE is 32 or 64,
+         as <https://bugs.gnu.org/78476> suggests that it fails when
+         W_TYPE_SIZE is 128 and the code has not been well tested with
+         other values.  FIXME: Either remove the single-precision
+         code, or fix its assumptions about W_TYPE_SIZE, perhaps by
+         using Baille-PSW as suggested in a FIXME above.  */
+      enum { SINGLE_WORKS = W_TYPE_SIZE == 32 || W_TYPE_SIZE == 64 };
+
+      if (SINGLE_WORKS && hi (u) >> (W_TYPE_SIZE - 1) == 0)
         {
           devmsg ("[using single-precision arithmetic] ");
           print_factors_single (u);