From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 27FCA3858D37; Thu, 29 Sep 2022 01:32:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 27FCA3858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664415154; bh=iUdcvmNhxcjbNaJpLPsH0ECsUEv1ckIzBiQAgC2NCsw=; h=From:To:Subject:Date:From; b=ujscAa4xPGdSPbB2957JFbblCEs2RDcGUkQ/1s7Eiq56ufXXZ+SDgIaqE+5i2+zzi MphWqFTHpAX8bvmcw47RpMQ0ZK0ZgmQveZN0QpJyy/eM6BG+1Mew7+JnQrS4X2DMyO c+Zst0GKGjGiA76xtltZxmwgdhY+ji6wY9ZMUSys= From: "francois.hebert001 at videotron dot ca" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/107081] New: ctime fct used twice in printf Date: Thu, 29 Sep 2022 01:32:33 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: francois.hebert001 at videotron dot ca X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107081 Bug ID: 107081 Summary: ctime fct used twice in printf Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: francois.hebert001 at videotron dot ca Target Milestone: --- If I use twice the ctime fct in the same printf, only the first value is pr= int twice. If I use two printf both val;ue are printed correctly : ... time_t now,now_beg,now_fin; ... printf("Beginning time ->%s Finishing time>%s\n",ctime(&now_beg),=20=20 ctime(&now_fin)); printf("Beginning time->%s\n",ctime(&now_beg)); printf("Finishing time->%s\n",ctime(&now_fin)); The result is : Sep 28 20:37:17 2022 Beginning time ->Wed Sep 28 20:37:15 2022 Finishing time->Wed Sep 28 20:37:15 2022 <- should be not 20:37:15 but 20:37:17 Beginning time->Wed Sep 28 20:37:15 2022 Finishing time->Wed Sep 28 20:37:17 2022 Here is the Linux and gcc versions and the complete source used /* gcc -o test_ctime test_ctime.c ./test_ctime Fedora 36 astronomy 5.17.5-300 gcc --version gcc (GCC) 12.0.1 20220413 (Red Hat 12.0.1-0) Copyright =C2=A9 2022 Free Software Foundation, Inc. */ #include #include #include long cpt; long j,limit; time_t now,now_beg,now_fin; /**************************************************************************= ***************** Main section ***************************************************************************= ****************/ int main() { cpt=3D0; j=3D0; /*limite=3DLONG_MAX;*/ limit=3D900000000; printf("Limit->%d\n",limit); time(&now_beg); printf("Begining time -> %s\n",ctime(&now_beg)); for (cpt=3D0;cpt%s\n",cpt,ctime(&now)); } } time(&now_fin); printf("Beginning time ->%s Finishing time->%s\n",=20 ctime(&now_beg),ctime(&now_fin)); printf("Beginning time->%s\n",ctime(&now_beg)); printf("Finishing time->%s\n",ctime(&now_fin)); return 0; } /* end main section */=