public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug time/29035] New: Output of mktime with latest gcc and glibc differs with their older version when is_dst flag set
@ 2022-04-07 9:56 shubham.jangam at druva dot com
2022-04-07 9:59 ` [Bug time/29035] " shubham.jangam at druva dot com
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: shubham.jangam at druva dot com @ 2022-04-07 9:56 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=29035
Bug ID: 29035
Summary: Output of mktime with latest gcc and glibc differs
with their older version when is_dst flag set
Product: glibc
Version: 2.32
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: time
Assignee: unassigned at sourceware dot org
Reporter: shubham.jangam at druva dot com
Target Milestone: ---
Hello,
(A)
There is one discrepancy with the behaviour of mktime() from version GCC 9.4.0
(glibc ver:2.31)
and GCC 7.5.0 (glibc ver: 2.27) when used.
I have referenced online docs as mentioned in point(C) below to understand this
function.
This sample(Mentioned in point(B)) tries to get time since the Epoch by giving
some random but valid date as
input using mktime.
(Sample code taken from man page).
I run this sample code on 2 different versions of gcc.
and observed different outputs when flag for tm_isdst was set.
Output(1) with gcc version: 9.4.0 and glibc version: 2.31
o/p:
-1 -unknown-
Output(2) with gcc version: 7.5.0 and glibc version: 2.27
o/p:
1649203201 Wednesday
When this code run on older version of gcc (gcc ver: 7.5.0, glibc ver: 2.31),
It outputs correctly.
But when I run same code with newer version of gcc (gcc ver: ). It returns
erroneous output which indicates some discrepancy
in functions behaviour compared as docs states.
As per man page,
A positive or 0 value for tm_isdst shall cause mktime() to presume initially
that Daylight Savings Time,
respectively, is or is not in effect for the specified time.
Buf if we provide positive value for tm_isdst, function fails with newer
version of gcc and glibc.
May be this whole behaviour is expected but seems not rightly mentioned on man
page.
(B)
Sample Code used from docs present as per internet given point(C):
```
#include <stdio.h>
#include <time.h>
char daybuf[20];
int main(void)
{
time_t tt;
struct tm time_str;
time_str.tm_year = 2022 - 1900;
time_str.tm_mon = 4 - 1;
time_str.tm_mday = 6;
time_str.tm_hour = 0;
time_str.tm_min = 0;
time_str.tm_sec = 1;
time_str.tm_isdst = 0;
tt = mktime(&time_str);
printf("%ld ", tt);
if(tt == -1)
{
(void)puts("-unknown-");
}
else
{
(void)strftime(daybuf, sizeof(daybuf), "%A", &time_str);
(void)puts(daybuf);
}
return 0;
}
```
(C)Docs referred:
https://pubs.opengroup.org/onlinepubs/7908799/xsh/mktime.html
https://man7.org/linux/man-pages/man3/mktime.3p.html
https://www.ibm.com/docs/de/zvm/7.1?topic=SSB27U_7.1.0/com.ibm.zvm.v710.edclv/mktime.htm
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug time/29035] Output of mktime with latest gcc and glibc differs with their older version when is_dst flag set
2022-04-07 9:56 [Bug time/29035] New: Output of mktime with latest gcc and glibc differs with their older version when is_dst flag set shubham.jangam at druva dot com
@ 2022-04-07 9:59 ` shubham.jangam at druva dot com
2022-04-07 10:13 ` schwab@linux-m68k.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: shubham.jangam at druva dot com @ 2022-04-07 9:59 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=29035
Shubham Jangam <shubham.jangam at druva dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Version|2.32 |2.31
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug time/29035] Output of mktime with latest gcc and glibc differs with their older version when is_dst flag set
2022-04-07 9:56 [Bug time/29035] New: Output of mktime with latest gcc and glibc differs with their older version when is_dst flag set shubham.jangam at druva dot com
2022-04-07 9:59 ` [Bug time/29035] " shubham.jangam at druva dot com
@ 2022-04-07 10:13 ` schwab@linux-m68k.org
2022-04-07 14:39 ` shubham.jangam at druva dot com
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: schwab@linux-m68k.org @ 2022-04-07 10:13 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=29035
--- Comment #1 from Andreas Schwab <schwab@linux-m68k.org> ---
Which timezone?
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug time/29035] Output of mktime with latest gcc and glibc differs with their older version when is_dst flag set
2022-04-07 9:56 [Bug time/29035] New: Output of mktime with latest gcc and glibc differs with their older version when is_dst flag set shubham.jangam at druva dot com
2022-04-07 9:59 ` [Bug time/29035] " shubham.jangam at druva dot com
2022-04-07 10:13 ` schwab@linux-m68k.org
@ 2022-04-07 14:39 ` shubham.jangam at druva dot com
2022-04-07 14:53 ` schwab@linux-m68k.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: shubham.jangam at druva dot com @ 2022-04-07 14:39 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=29035
--- Comment #2 from Shubham Jangam <shubham.jangam at druva dot com> ---
IST +0530
But, Mostly this will be same even with UTC +0000.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug time/29035] Output of mktime with latest gcc and glibc differs with their older version when is_dst flag set
2022-04-07 9:56 [Bug time/29035] New: Output of mktime with latest gcc and glibc differs with their older version when is_dst flag set shubham.jangam at druva dot com
` (2 preceding siblings ...)
2022-04-07 14:39 ` shubham.jangam at druva dot com
@ 2022-04-07 14:53 ` schwab@linux-m68k.org
2022-04-11 6:44 ` shubham.jangam at druva dot com
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: schwab@linux-m68k.org @ 2022-04-07 14:53 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=29035
--- Comment #3 from Andreas Schwab <schwab@linux-m68k.org> ---
I cannot reproduce that with 2.35.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug time/29035] Output of mktime with latest gcc and glibc differs with their older version when is_dst flag set
2022-04-07 9:56 [Bug time/29035] New: Output of mktime with latest gcc and glibc differs with their older version when is_dst flag set shubham.jangam at druva dot com
` (3 preceding siblings ...)
2022-04-07 14:53 ` schwab@linux-m68k.org
@ 2022-04-11 6:44 ` shubham.jangam at druva dot com
2022-04-11 6:45 ` shubham.jangam at druva dot com
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: shubham.jangam at druva dot com @ 2022-04-11 6:44 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=29035
--- Comment #4 from Shubham Jangam <shubham.jangam at druva dot com> ---
Created attachment 14056
--> https://sourceware.org/bugzilla/attachment.cgi?id=14056&action=edit
Screenshot for different outputs
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug time/29035] Output of mktime with latest gcc and glibc differs with their older version when is_dst flag set
2022-04-07 9:56 [Bug time/29035] New: Output of mktime with latest gcc and glibc differs with their older version when is_dst flag set shubham.jangam at druva dot com
` (4 preceding siblings ...)
2022-04-11 6:44 ` shubham.jangam at druva dot com
@ 2022-04-11 6:45 ` shubham.jangam at druva dot com
2022-04-11 6:50 ` shubham.jangam at druva dot com
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: shubham.jangam at druva dot com @ 2022-04-11 6:45 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=29035
--- Comment #5 from Shubham Jangam <shubham.jangam at druva dot com> ---
I tried to reproduce this on 2.35, I was successful.
I have attached screenshot for run output.
For version 2.31, I also checked on UTC timezone, it was able to reproduce
there too.
Please let me know if I am missing anything.
Thanks,
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug time/29035] Output of mktime with latest gcc and glibc differs with their older version when is_dst flag set
2022-04-07 9:56 [Bug time/29035] New: Output of mktime with latest gcc and glibc differs with their older version when is_dst flag set shubham.jangam at druva dot com
` (5 preceding siblings ...)
2022-04-11 6:45 ` shubham.jangam at druva dot com
@ 2022-04-11 6:50 ` shubham.jangam at druva dot com
2022-04-13 7:48 ` shubham.jangam at druva dot com
2022-04-20 4:36 ` shubham.jangam at druva dot com
8 siblings, 0 replies; 10+ messages in thread
From: shubham.jangam at druva dot com @ 2022-04-11 6:50 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=29035
--- Comment #6 from Shubham Jangam <shubham.jangam at druva dot com> ---
I tried to reproduce this on 2.35, I was successful.
I have attached screenshot for run output.
For version 2.31, I also checked on UTC timezone, it was able to reproduce
there too.
Please let me know if I am missing anything.
Thanks,
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug time/29035] Output of mktime with latest gcc and glibc differs with their older version when is_dst flag set
2022-04-07 9:56 [Bug time/29035] New: Output of mktime with latest gcc and glibc differs with their older version when is_dst flag set shubham.jangam at druva dot com
` (6 preceding siblings ...)
2022-04-11 6:50 ` shubham.jangam at druva dot com
@ 2022-04-13 7:48 ` shubham.jangam at druva dot com
2022-04-20 4:36 ` shubham.jangam at druva dot com
8 siblings, 0 replies; 10+ messages in thread
From: shubham.jangam at druva dot com @ 2022-04-13 7:48 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=29035
--- Comment #7 from Shubham Jangam <shubham.jangam at druva dot com> ---
For Info,
Output(1)
With GLIBC 2.35 and gcc 11.2.0
shubhamj-Standard-PC:~$ sudo timedatectl set-timezone GMT+0
shubhamj-Standard-PC:~$ ./a.out
-1 -unknown-
shubhamj-Standard-PC:~$ sudo timedatectl set-timezone Etc/UTC
shubhamj-Standard-PC:~$ ./a.out
-1 -unknown-
shubhamj-Standard-PC:~$ sudo timedatectl set-timezone America/Denver
shubhamj-Standard-PC:~$ ./a.out
1649224801 Wednesday
_________________________________________________________________
Output(2)
With GLIBC 2.27 and gcc 7.5.0
root@Shubham:~# set timedatectl set-timezone GMT+0
root@Shubham:~# ./a.out
1649203201 Wednesday
root@Shubham:~# set timedatectl set-timezone Etc/UTC
root@Shubham:~# ./a.out
1649203201 Wednesday
root@Shubham:~# set timedatectl set-timezone America/Denver
root@Shubham:~# ./a.out
1649203201 Wednesday
***
I hope this makes things clear.
Code used:
#include <stdio.h>
#include <time.h>
char daybuf[20];
int main(void)
{
time_t tt;
struct tm time_str;
time_str.tm_year = 2022 - 1900;
time_str.tm_mon = 4 - 1;
time_str.tm_mday = 6;
time_str.tm_hour = 0;
time_str.tm_min = 0;
time_str.tm_sec = 1;
time_str.tm_isdst = 1;
tt = mktime(&time_str);
printf("%ld ", tt);
if(tt == -1){
(void)puts("-unknown-");
}
else{
(void)strftime(daybuf, sizeof(daybuf), "%A", &time_str);
(void)puts(daybuf);
}
return 0;
}
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug time/29035] Output of mktime with latest gcc and glibc differs with their older version when is_dst flag set
2022-04-07 9:56 [Bug time/29035] New: Output of mktime with latest gcc and glibc differs with their older version when is_dst flag set shubham.jangam at druva dot com
` (7 preceding siblings ...)
2022-04-13 7:48 ` shubham.jangam at druva dot com
@ 2022-04-20 4:36 ` shubham.jangam at druva dot com
8 siblings, 0 replies; 10+ messages in thread
From: shubham.jangam at druva dot com @ 2022-04-20 4:36 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=29035
--- Comment #8 from Shubham Jangam <shubham.jangam at druva dot com> ---
Hi Andreas,
Was you able to reproduce the issue and confirm?
Thank you for your time and efforts,
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2022-04-20 4:36 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-07 9:56 [Bug time/29035] New: Output of mktime with latest gcc and glibc differs with their older version when is_dst flag set shubham.jangam at druva dot com
2022-04-07 9:59 ` [Bug time/29035] " shubham.jangam at druva dot com
2022-04-07 10:13 ` schwab@linux-m68k.org
2022-04-07 14:39 ` shubham.jangam at druva dot com
2022-04-07 14:53 ` schwab@linux-m68k.org
2022-04-11 6:44 ` shubham.jangam at druva dot com
2022-04-11 6:45 ` shubham.jangam at druva dot com
2022-04-11 6:50 ` shubham.jangam at druva dot com
2022-04-13 7:48 ` shubham.jangam at druva dot com
2022-04-20 4:36 ` shubham.jangam at druva dot com
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).