public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c/4177: in printf only first call to asctime(localtime(..)) is evaluated
@ 2001-08-30 4:56 joachim.wuttke
0 siblings, 0 replies; 2+ messages in thread
From: joachim.wuttke @ 2001-08-30 4:56 UTC (permalink / raw)
To: gcc-gnats; +Cc: jwuttke
>Number: 4177
>Category: c
>Synopsis: in printf only first call to asctime(localtime(..)) is evaluated
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Thu Aug 30 04:56:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: Joachim Wuttke
>Release: 2.95.03
>Organization:
>Environment:
rtlinux
>Description:
wrong: Mon Mar 23 01:26:40 1970 Mon Mar 23 01:26:40 1970
correct: Mon Mar 23 01:26:40 1970 Fri Jan 9 02:32:03 1976
>How-To-Repeat:
#include <stdio.h>
#include <sys/time.h>
main()
{
long i=7000000, p=189999123;
printf("wrong: %.24s %.24s\n", asctime(localtime(&i)),
asctime(localtime(&p)));
printf("correct: %.24s", asctime(localtime(&i)));
printf( " %.24s\n", asctime(localtime(&p)));
}
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: c/4177: in printf only first call to asctime(localtime(..)) is evaluated
@ 2001-08-31 5:07 aoliva
0 siblings, 0 replies; 2+ messages in thread
From: aoliva @ 2001-08-31 5:07 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, joachim.wuttke, jwuttke, nobody
Synopsis: in printf only first call to asctime(localtime(..)) is evaluated
State-Changed-From-To: open->closed
State-Changed-By: aoliva
State-Changed-When: Fri Aug 31 05:07:34 2001
State-Changed-Why:
asctime() returns a pointer to a statically allocated area. You call it twice before pritnf has a chance to use the value written after the first call.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=4177&database=gcc
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2001-08-31 5:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-30 4:56 c/4177: in printf only first call to asctime(localtime(..)) is evaluated joachim.wuttke
2001-08-31 5:07 aoliva
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).