public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dave at hiauly1 dot hia.nrc.ca" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libfortran/47802] [4.6 Regression] libgfortran/intrinsics/ctime.c:75:3: error: too few arguments to function 'ctime_r'
Date: Fri, 18 Feb 2011 21:13:00 -0000	[thread overview]
Message-ID: <bug-47802-4-uIxBkNZAAK@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-47802-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47802

--- Comment #2 from dave at hiauly1 dot hia.nrc.ca 2011-02-18 20:56:54 UTC ---
> Is there no way to get a posix compliant ctime?  Alternatively, we'll need
> autoconf magic to detect the extra arg.  I know at one time it was relatively
> common, so autoconf magic might be around somewhere.  Assuming it is you just
> have to do something like
> 
> 
> #if defined (oddballctime)
>   *date = ctime_r (&now, cbuf, CSZ);
> #else
>   *date = ctime_r (&now, cbuf);
> #endif

Using ctime_r is a bit of a can of worms.  The GNU autoconf manual recommends
not using ctime_r unless the inputs are known to be within certain limits.

It seems HP-UX and Solaris have both forms.  In the HP-UX 11 case,
which form is used at compilation time depends on _PTHREADS_DRAFT4:

#          ifndef _PTHREADS_DRAFT4
             extern char *ctime_r(const __time_t *, char *);
#          else /* _PTHREADS_DRAFT4 */
         extern int ctime_r(const __time_t *, char *, int);
#          endif /* _PTHREADS_DRAFT4 */

Potential autoconf test:

# ctime_r --
#
# There are two versions of ctime_r, one of which takes a buffer length as a
# third argument, and one which only takes two arguments.  (There is also a
# difference in return values, but we handle that in the code itself.)
AC_CHECK_FUNCS(ctime_r)
if test "$ac_cv_func_ctime_r" = "yes"; then
AC_CACHE_CHECK([for 2 or 3 argument version of ctime_r], db_cv_ctime_r_3arg, [
AC_TRY_LINK([
#include <time.h>], [
    ctime_r(NULL, NULL, 100);
],  [db_cv_ctime_r_3arg="3-argument"], [db_cv_ctime_r_3arg="2-argument"])])
fi
if test "$db_cv_ctime_r_3arg" = "3-argument"; then
    AC_DEFINE(HAVE_CTIME_R_3ARG)
    AH_TEMPLATE(HAVE_CTIME_R_3ARG,
        [Define to 1 if ctime_r takes a buffer length as a third argument.])
fi

Dave


  parent reply	other threads:[~2011-02-18 20:57 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-18 16:53 [Bug libfortran/47802] New: " danglin at gcc dot gnu.org
2011-02-18 17:07 ` [Bug libfortran/47802] [4.6 Regression] " burnus at gcc dot gnu.org
2011-02-18 19:55 ` law at redhat dot com
2011-02-18 20:16 ` law at redhat dot com
2011-02-18 21:13 ` dave at hiauly1 dot hia.nrc.ca [this message]
2011-02-19 17:30 ` jb at gcc dot gnu.org
2011-02-19 17:31 ` danglin at gcc dot gnu.org
2011-02-19 17:49 ` danglin at gcc dot gnu.org
2011-02-21 17:05 ` law at redhat dot com
2011-02-21 17:43 ` jakub at gcc dot gnu.org
2011-02-21 18:49 ` burnus at gcc dot gnu.org
2011-02-21 18:51 ` law at redhat dot com
2011-02-21 18:53 ` law at redhat dot com
2011-02-21 19:10 ` jakub at gcc dot gnu.org
2011-02-21 19:47 ` dave at hiauly1 dot hia.nrc.ca
2011-02-22  9:31 ` jb at gcc dot gnu.org
2011-02-22  9:36 ` jakub at gcc dot gnu.org
2011-02-22 16:41 ` jb at gcc dot gnu.org
2011-02-22 20:44 ` jb at gcc dot gnu.org
2011-02-23 14:30 ` dave at hiauly1 dot hia.nrc.ca
2011-02-23 14:35 ` dave at hiauly1 dot hia.nrc.ca
2011-02-23 18:32 ` burnus at gcc dot gnu.org
2011-02-23 20:55 ` dave at hiauly1 dot hia.nrc.ca
2011-02-24 12:52 ` jb at gcc dot gnu.org
2011-02-24 14:56 ` jb at gcc dot gnu.org
2011-02-24 15:05 ` dave at hiauly1 dot hia.nrc.ca
2011-02-24 21:54 ` jb at gcc dot gnu.org
2011-02-25 10:58 ` burnus at gcc dot gnu.org
2011-02-26 14:05 ` dave at hiauly1 dot hia.nrc.ca
2011-03-02 13:52 ` jakub at gcc dot gnu.org
2011-03-02 13:58 ` law at redhat dot com
2011-03-02 14:01 ` jakub at gcc dot gnu.org
2011-03-03 13:57 ` dave at hiauly1 dot hia.nrc.ca
2011-03-04 17:37 ` jb at gcc dot gnu.org
2011-03-04 17:53 ` jb at gcc dot gnu.org
2011-03-04 19:08 ` jb at gcc dot gnu.org
2011-03-04 19:15 ` jb at gcc dot gnu.org
2011-03-05 17:06 ` dave at hiauly1 dot hia.nrc.ca
2011-03-09  7:48 ` jb at gcc dot gnu.org
2011-03-09 13:42 ` burnus at gcc dot gnu.org
2011-03-10 16:59 ` dave at hiauly1 dot hia.nrc.ca

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-47802-4-uIxBkNZAAK@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).