bug-gnulib
[Top][All Lists]
Advanced

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

Re: time_r.m4 checks unexpectedly pass on hpux10


From: Bruno Haible
Subject: Re: time_r.m4 checks unexpectedly pass on hpux10
Date: Fri, 22 Feb 2008 23:54:12 +0100
User-agent: KMail/1.5.4

Hi,

Peter O'Gorman wrote:

> HP-UX10 has:
> int gmtime_r(const time_t *timer, struct tm *result);
> int localtime_r(const time_t *timer, struct tm *result);
> 
> Which is, as you know, not standards conforming.
> 
> However, compiling the test case for reentrant time functions on
> hpux10 with its native cc and -Ae results in a compiler warning, not
> an error. So the test, unfortunately, passes.
> 
> The test case is:
> #include <time.h>
> 
> int main() {
> /* We don't need to append 'restrict's to the argument types,
>    even though the POSIX signature has the 'restrict's,   
>    since C99 says they can't affect type compatibility.  */
>    struct tm * (*ptr) (time_t const *, struct tm *) = localtime_r;
>    if (ptr) return 0;
> }
> 
> The compile line and warning:
> cc -Ae -c lcltimecheck.c -D_REENTRANT             
> cc: "lcltimecheck.c", line 7: warning 604: Pointers are not 
> assignment-compatible.

Thanks for reporting this.

> Perhaps we should set ac_c_werror_flag=yes before running this test?

ac_c_werror_flag is undocumented. I wouldn't use it. There is a documented
macro AC_LANG_WERROR, but I'd prefer not to use it, because there are
compilers that spew warnings on every invocation.

How about this proposed patch? Does it work for you?

Paul, is this ok to commit?

Bruno


2008-02-22  Bruno Haible  <address@hidden>

        * m4/time_r.m4 (gl_TIME_R): Also check that localtime_r's return type
        is a pointer type.  Needed for HP-UX 10.
        * doc/posix-functions/localtime_r.texi: Mention HP-UX 10.
        * doc/posix-functions/gmtime_r.texi: Likewise.
        Reported by Peter O'Gorman <address@hidden>.

*** m4/time_r.m4.orig   2008-02-22 23:49:16.000000000 +0100
--- m4/time_r.m4        2008-02-22 23:45:41.000000000 +0100
***************
*** 1,6 ****
  dnl Reentrant time functions like localtime_r.
  
! dnl Copyright (C) 2003, 2006, 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,6 ----
  dnl Reentrant time functions like localtime_r.
  
! dnl Copyright (C) 2003, 2006, 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.
***************
*** 23,29 ****
           even though the POSIX signature has the 'restrict's,
           since C99 says they can't affect type compatibility.  */
        struct tm * (*ptr) (time_t const *, struct tm *) = localtime_r;
!         if (ptr) return 0;],
         [gl_cv_time_r_posix=yes],
         [gl_cv_time_r_posix=no])])
    if test $gl_cv_time_r_posix = yes; then
--- 23,31 ----
           even though the POSIX signature has the 'restrict's,
           since C99 says they can't affect type compatibility.  */
        struct tm * (*ptr) (time_t const *, struct tm *) = localtime_r;
!         if (ptr) return 0;
!         /* Check the return type is a pointer.  On HP-UX 10 it is 'int'.  */
!         *localtime_r (0, 0);],
         [gl_cv_time_r_posix=yes],
         [gl_cv_time_r_posix=no])])
    if test $gl_cv_time_r_posix = yes; then
*** doc/posix-functions/gmtime_r.texi.orig      2008-02-22 23:49:16.000000000 
+0100
--- doc/posix-functions/gmtime_r.texi   2008-02-22 23:48:16.000000000 +0100
***************
*** 16,20 ****
  This function is missing on some platforms:
  mingw.
  @item
! Some platforms define a function of this name that is incompatible to POSIX.
  @end itemize
--- 16,21 ----
  This function is missing on some platforms:
  mingw.
  @item
! Some platforms define a function of this name that is incompatible to POSIX:
! HP-UX 10.
  @end itemize
*** doc/posix-functions/localtime_r.texi.orig   2008-02-22 23:49:16.000000000 
+0100
--- doc/posix-functions/localtime_r.texi        2008-02-22 23:48:16.000000000 
+0100
***************
*** 16,20 ****
  This function is missing on some platforms:
  mingw.
  @item
! Some platforms define a function of this name that is incompatible to POSIX.
  @end itemize
--- 16,21 ----
  This function is missing on some platforms:
  mingw.
  @item
! Some platforms define a function of this name that is incompatible to POSIX:
! HP-UX 10.
  @end itemize






reply via email to

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