autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug in AC_FUNC_MEMCMP [Re: Autoconf 2.49e


From: Jim Meyering
Subject: bug in AC_FUNC_MEMCMP [Re: Autoconf 2.49e
Date: 22 Apr 2001 11:56:53 +0200
User-agent: Gnus/5.090003 (Oort Gnus v0.03) Emacs/21.0.103

Akim Demaille <address@hidden> wrote:
| Autoconf 2.49e is available as
|
|         ftp://alpha.gnu.org/gnu/autoconf/autoconf-2.49e.tar.gz
...
| Please test it, stress it, torture it.

Hi Akim,

In comparing config.cache for fileutils on a SunOS system
before and after the switch to autoconf-2.49e, I noticed
that (with an old gcc) the SunOS system is no longer using
the memcmp replacement function.

That turned out to be due to a typo in acfunctions.m4 that induced
the following syntax in configure (note the extra `main').
Interestingly, the test program compiles and links without error
and always exits successfully.

    cat >conftest.$ac_ext <<_ACEOF
  #line 12151 "configure"
  #include "confdefs.h"

  int
  main ()
  {

  int
  main ()
  {
    /* Some versions of memcmp are not 8-bit clean.  */
    char c0 = 0x40, c1 = 0x80, c2 = 0x81;
    if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0)
      exit (1);

    /* The Next x86 OpenStep bug shows up only when comparing 16 bytes
       or more and with at least one buffer not starting on a 4-byte boundary.
       William Lewis provided this test program.   */
    {
      char foo[21];
      char bar[21];
      int i;
      for (i = 0; i < 4; i++)
        {
          char *a = foo + i;
          char *b = bar + i;
          strcpy (a, "--------01111111");
          strcpy (b, "--------10000000");
          if (memcmp (a, b, 16) >= 0)
            exit (1);
        }
      exit (0);
    }
  }
    ;
    return 0;
  }
  _ACEOF
------------------------

Here's a patch that is probably what was intended:

2001-04-22  Jim Meyering  <address@hidden>

        * acfunctions.m4 (AC_FUNC_MEMCMP): Remove `int main () {' and the
        trailing `}' since AC_LANG_PROGRAM provides them.

Index: acfunctions.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/acfunctions.m4,v
retrieving revision 1.32
diff -u -p -r1.32 acfunctions.m4
--- acfunctions.m4      2001/03/19 18:14:44     1.32
+++ acfunctions.m4      2001/04/22 09:42:50
@@ -733,9 +733,6 @@ fi
 AC_DEFUN([AC_FUNC_MEMCMP],
 [AC_CACHE_CHECK([for working memcmp], ac_cv_func_memcmp_working,
 [AC_RUN_IFELSE([AC_LANG_PROGRAM([], [[
-int
-main ()
-{
   /* Some versions of memcmp are not 8-bit clean.  */
   char c0 = 0x40, c1 = 0x80, c2 = 0x81;
   if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0)
@@ -759,7 +756,7 @@ main ()
       }
     exit (0);
   }
-}]])],
+]])],
                [ac_cv_func_memcmp_working=yes],
                [ac_cv_func_memcmp_working=no],
                [ac_cv_func_memcmp_working=no])])



reply via email to

[Prev in Thread] Current Thread [Next in Thread]