Paul Eggert wrote: > I ran into this problem when compiling coreutils 6.10 on Solaris 8 > (sparc) with GCC 4.2.2: > > frexp.c: In function 'rpl_frexpl': > frexp.c:63: warning: implicit declaration of function 'isnanl' > vasnprintf.c: In function 'is_infinitel': > vasnprintf.c:252: warning: implicit declaration of function 'isnanl' > > Here, the problem is that isnanl is defined by libm, but it's not > declared anywhere in /usr/include.
If that was the problem, one would also see the warning when gcc-3.x is used. And I can see with "nm" that libm on Solaris 8 does not have 'isnanl'. The problem is that GCC knows about isnanl as a built-in function. It is compiled like __builtin_isnanl (supported by GCC >= 4.0), but gives a warning. > Here's a patch: > > 2008-01-24 Paul Eggert <[EMAIL PROTECTED]> > > * m4/isnanl.m4: Check that isnanl is declared, when it's used. > (gl_HAVE_ISNANL_NO_LIBM, gl_HAVE_ISNANL_IN_LIBM): Check that > isnanl is declared, if we are not going to override it anyway. > This suppresses a warning when compiling coreutils 6.10 with GCC > 4.2.2 on Solaris 8. In that combination, no include file defines > isnanl, but it's in libm, and GCC issues a warning when compiling. Although your patch is correct, I prefer not to use it: It has the effect to reject GCC's built-in. Instead I find it better to use this built-in (on those platforms where it works), since that will save a function call. GCC's built-in does not pass our tests on x86, x86_64, ia64. But the libc function does not do either. So it's acceptable to prefer the GCC built-in to the libc implementation always. Committed this: 2008-01-26 Bruno Haible <[EMAIL PROTECTED]> * m4/isnanl.m4 (gl_HAVE_ISNANL_NO_LIBM, gl_HAVE_ISNANL_IN_LIBM, gl_FUNC_ISNANL_WORKS): Test the GCC >= 4.0 built-in. * lib/isnanl.h (isnanl): Use the GCC >= 4.0 built-in. * lib/isnanl-nolibm.h (isnanl): Likewise. Reported by Paul Eggert <[EMAIL PROTECTED]>. *** lib/isnanl-nolibm.h.orig 2008-01-26 15:41:57.000000000 +0100 --- lib/isnanl-nolibm.h 2008-01-26 15:39:22.000000000 +0100 *************** *** 1,5 **** /* Test for NaN that does not need libm. ! Copyright (C) 2007 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by --- 1,5 ---- /* Test for NaN that does not need libm. ! Copyright (C) 2007-2008 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by *************** *** 17,23 **** #if HAVE_ISNANL_IN_LIBC /* Get declaration of isnan macro or (older) isnanl function. */ # include <math.h> ! # ifdef isnan # undef isnanl # define isnanl(x) isnan ((long double)(x)) # endif --- 17,27 ---- #if HAVE_ISNANL_IN_LIBC /* Get declaration of isnan macro or (older) isnanl function. */ # include <math.h> ! # if __GNUC__ >= 4 ! /* GCC 4.0 and newer provides three built-ins for isnan. */ ! # undef isnanl ! # define isnanl(x) __builtin_isnanl ((long double)(x)) ! # elif defined isnan # undef isnanl # define isnanl(x) isnan ((long double)(x)) # endif *** lib/isnanl.h.orig 2008-01-26 15:41:57.000000000 +0100 --- lib/isnanl.h 2008-01-26 15:39:22.000000000 +0100 *************** *** 1,5 **** /* Test for NaN. ! Copyright (C) 2007 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by --- 1,5 ---- /* Test for NaN. ! Copyright (C) 2007-2008 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by *************** *** 17,23 **** #if HAVE_ISNANL /* Get declaration of isnan macro or (older) isnanl function. */ # include <math.h> ! # ifdef isnan # undef isnanl # define isnanl(x) isnan ((long double)(x)) # endif --- 17,27 ---- #if HAVE_ISNANL /* Get declaration of isnan macro or (older) isnanl function. */ # include <math.h> ! # if __GNUC__ >= 4 ! /* GCC 4.0 and newer provides three built-ins for isnan. */ ! # undef isnanl ! # define isnanl(x) __builtin_isnanl ((long double)(x)) ! # elif defined isnan # undef isnanl # define isnanl(x) isnan ((long double)(x)) # endif *** m4/isnanl.m4.orig 2008-01-26 15:41:57.000000000 +0100 --- m4/isnanl.m4 2008-01-26 15:39:22.000000000 +0100 *************** *** 1,5 **** ! # isnanl.m4 serial 5 ! dnl Copyright (C) 2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. --- 1,5 ---- ! # isnanl.m4 serial 6 ! dnl Copyright (C) 2007-2008 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. *************** *** 64,70 **** [gl_cv_func_isnanl_no_libm], [ AC_TRY_LINK([#include <math.h> ! #ifdef isnan # undef isnanl # define isnanl(x) isnan ((long double)(x)) #endif --- 64,73 ---- [gl_cv_func_isnanl_no_libm], [ AC_TRY_LINK([#include <math.h> ! #if __GNUC__ >= 4 ! # undef isnanl ! # define isnanl(x) __builtin_isnanl ((long double)(x)) ! #elif defined isnan # undef isnanl # define isnanl(x) isnan ((long double)(x)) #endif *************** *** 84,90 **** save_LIBS="$LIBS" LIBS="$LIBS -lm" AC_TRY_LINK([#include <math.h> ! #ifdef isnan # undef isnanl # define isnanl(x) isnan ((long double)(x)) #endif --- 87,96 ---- save_LIBS="$LIBS" LIBS="$LIBS -lm" AC_TRY_LINK([#include <math.h> ! #if __GNUC__ >= 4 ! # undef isnanl ! # define isnanl(x) __builtin_isnanl ((long double)(x)) ! #elif defined isnan # undef isnanl # define isnanl(x) isnan ((long double)(x)) #endif *************** *** 98,103 **** --- 104,112 ---- dnl Test whether isnanl() recognizes all numbers which are neither finite nor dnl infinite. This test fails e.g. on NetBSD/i386 and on glibc/ia64. + dnl Also, the GCC >= 4.0 built-in __builtin_isnanl does not pass the tests + dnl - for pseudo-denormals on i686 and x86_64, + dnl - for pseudo-zeroes, unnormalized numbers, and pseudo-denormals on ia64. AC_DEFUN([gl_FUNC_ISNANL_WORKS], [ AC_REQUIRE([AC_PROG_CC]) *************** *** 109,115 **** #include <float.h> #include <limits.h> #include <math.h> ! #ifdef isnan # undef isnanl # define isnanl(x) isnan ((long double)(x)) #endif --- 118,127 ---- #include <float.h> #include <limits.h> #include <math.h> ! #if __GNUC__ >= 4 ! # undef isnanl ! # define isnanl(x) __builtin_isnanl ((long double)(x)) ! #elif defined isnan # undef isnanl # define isnanl(x) isnan ((long double)(x)) #endif _______________________________________________ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils