AC_FUNC_MBRTOWC: Don't assume that a function F exists merely because

the compiler and linker let you compile an expression like (F != 0).
This commit is contained in:
Paul Eggert 2004-05-24 23:18:04 +00:00
parent 77cf219604
commit 3999390896
2 changed files with 13 additions and 1 deletions

View File

@ -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

View 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