From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10172 invoked by alias); 12 Sep 2019 18:16:33 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 10164 invoked by uid 89); 12 Sep 2019 18:16:33 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=BAYES_00,FROM_STARTS_WITH_NUMS,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=no version=3.3.1 spammy=HX-PHP-Originating-Script:rcmail.php, HX-Languages-Length:1053, H*u:0.9.2, H*UA:0.9.2 X-HELO: smtp-out-no.shaw.ca Received: from smtp-out-no.shaw.ca (HELO smtp-out-no.shaw.ca) (64.59.134.13) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 12 Sep 2019 18:16:31 +0000 Received: from kylheku.com ([70.79.163.252]) by shaw.ca with ESMTPA id 8TdriedlQUIS28TdsifrSM; Thu, 12 Sep 2019 12:16:29 -0600 Received: from www-data by kylheku.com with local (Exim 4.72) (envelope-from <920-082-4242@kylheku.com>) id 1i8Tdr-0004db-73 for cygwin@cygwin.com; Thu, 12 Sep 2019 11:16:27 -0700 To: cygwin@cygwin.com Subject: Re: Bug in TIME function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Date: Thu, 12 Sep 2019 18:44:00 -0000 From: Kaz Kylheku <920-082-4242@kylheku.com> In-Reply-To: <009d01d56994$a8065040$f812f0c0$@twcny.rr.com> References: <009d01d56994$a8065040$f812f0c0$@twcny.rr.com> Message-ID: X-Sender: 920-082-4242@kylheku.com User-Agent: Roundcube Webmail/0.9.2 X-IsSubscribed: yes X-SW-Source: 2019-09/txt/msg00143.txt.bz2 On 2019-09-12 11:05, tlake@twcny.rr.com wrote: > The code below returns -1. It shouldn't. Says who? I don't see anything in the specification which says that a null pointer=20 argument is allowed: https://pubs.opengroup.org/onlinepubs/9699919799/functions/times.html Passing a null pointer to an ISO C or POSIX library function results in=20 undefined behavior, except where it is documented otherwise. GNU/Linux (specifically the Glibc implementation of libc) also doesn't document any such extension (being able to pass a null pointer to=20 times). So even in light of the goal of Cygwin providing GNU/Linux compatibility beyond POSIX, there is no justification for supporting times(0). > #include > #include >=20 > int main(int argc, char *argv[]) >=20 > { > printf("return value %ld\n", (long)times((struct tms*)0)); The pointer cast is not required here; you have a prototype of the times function in scope; the equivalent times(0) will give you the undefined behavior you're asking for. > return 0; > } -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple