]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
AC_FUNC_MBRTOWC: Don't assume that a function F exists merely because
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 24 May 2004 23:18:04 +0000 (23:18 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 24 May 2004 23:18:04 +0000 (23:18 +0000)
the compiler and linker let you compile an expression like (F != 0).

ChangeLog
lib/autoconf/functions.m4

index ba88bfca14e24dee8ff40542c4568e7992918492..de912a80f99b0f2f9d2a41950b5bc1b7db6a8953 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2004-05-24  Paul Eggert  <eggert@cs.ucla.edu>
 
+       * lib/autoconf/functions.m4 (AC_FUNC_MBRTOWC): Don't assume that a
+       function F exists if the compiler and linker let you compile an
+       expression like (F != 0).  Recent versions of GCC optimize away
+       the reference to F in that case, since every function address must
+       be nonzero, so the link succeeds even if F does not exist.
+       Problem reported by Manu in
+       <http://mail.gnu.org/archive/html/bug-gnu-utils/2004-05/msg00060.html>.
+
        * doc/autoconf.texi (Systemology): Standardize on the spelling of
        "Unix".  Many uses changed.
        (Limitations of Builtins): Explain better why the ! command isn't
index e5a38f52fcdbf66925e2eb6f44379df3b025b7b3..b752c2968af426e89d90cce230c10617633dce1e 100644 (file)
@@ -889,7 +889,11 @@ AC_DEFUN([AC_FUNC_MBRTOWC],
     [AC_LINK_IFELSE(
        [AC_LANG_PROGRAM(
            [[@%:@include <wchar.h>]],
-           [[mbstate_t state; return ! (sizeof state && mbrtowc);]])],
+           [[wchar_t wc;
+             char const s[] = "";
+             size_t n = 1;
+             mbstate_t state;
+             return ! (sizeof state && (mbrtowc) (&wc, s, n, &state));]])],
        ac_cv_func_mbrtowc=yes,
        ac_cv_func_mbrtowc=no)])
   if test $ac_cv_func_mbrtowc = yes; then