public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/103612] New: get_time parsing error for two digits year
@ 2021-12-08 3:01 pyaggi at gmail dot com
2021-12-08 3:05 ` [Bug libstdc++/103612] " pinskia at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: pyaggi at gmail dot com @ 2021-12-08 3:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103612
Bug ID: 103612
Summary: get_time parsing error for two digits year
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: pyaggi at gmail dot com
Target Milestone: ---
std::get_time is behaving in the same way when the format includes '%y' or
'%Y', in both cases it tries to read a four digit year.
Example Code:
-------------
#include <iostream>
#include <iomanip>
void testDate(const char *format,const char *date)
{
std::istringstream ds(date);
std::tm tm = {};
ds >> std::get_time(&tm,format);
std::cout<<date<<" parsed using "<<format<<" -> Year: "<<tm.tm_year+1900<<"
Month: "<<tm.tm_mon<<" Day: "<<tm.tm_mday<<std::endl;
}
int main()
{
testDate("%y%m%d","101112");
testDate("%Y%m%d","101112");
testDate("%y%m%d","20101112");
testDate("%Y%m%d","20101112");
return 0;
}
Output:
-------
101112 parsed using %y%m%d -> Year: 1011 Month: 11 Day: 0
101112 parsed using %Y%m%d -> Year: 1011 Month: 11 Day: 0
20101112 parsed using %y%m%d -> Year: 2010 Month: 10 Day: 12
20101112 parsed using %Y%m%d -> Year: 2010 Month: 10 Day: 12
Tested with:
------------
g++ (SUSE Linux) 11.2.1 20210816
clang++ version 12.0.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libstdc++/103612] get_time parsing error for two digits year
2021-12-08 3:01 [Bug libstdc++/103612] New: get_time parsing error for two digits year pyaggi at gmail dot com
@ 2021-12-08 3:05 ` pinskia at gcc dot gnu.org
2021-12-08 3:45 ` pyaggi at gmail dot com
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-08 3:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103612
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=101152
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 101152 ?
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libstdc++/103612] get_time parsing error for two digits year
2021-12-08 3:01 [Bug libstdc++/103612] New: get_time parsing error for two digits year pyaggi at gmail dot com
2021-12-08 3:05 ` [Bug libstdc++/103612] " pinskia at gcc dot gnu.org
@ 2021-12-08 3:45 ` pyaggi at gmail dot com
2022-05-02 4:36 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pyaggi at gmail dot com @ 2021-12-08 3:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103612
--- Comment #2 from Pablo <pyaggi at gmail dot com> ---
(In reply to Andrew Pinski from comment #1)
> Dup of bug 101152 ?
No, I don't think so. Here the problem is %y acts like %Y, it uses 4 digits of
the input, and It doesn't produce an error even in the case where there is not
enough digits to complete the parse.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libstdc++/103612] get_time parsing error for two digits year
2021-12-08 3:01 [Bug libstdc++/103612] New: get_time parsing error for two digits year pyaggi at gmail dot com
2021-12-08 3:05 ` [Bug libstdc++/103612] " pinskia at gcc dot gnu.org
2021-12-08 3:45 ` pyaggi at gmail dot com
@ 2022-05-02 4:36 ` pinskia at gcc dot gnu.org
2022-05-02 4:38 ` [Bug libstdc++/103612] get_time %y " pinskia at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-05-02 4:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103612
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |fsb4000 at yandex dot ru
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 105450 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libstdc++/103612] get_time %y parsing error for two digits year
2021-12-08 3:01 [Bug libstdc++/103612] New: get_time parsing error for two digits year pyaggi at gmail dot com
` (2 preceding siblings ...)
2022-05-02 4:36 ` pinskia at gcc dot gnu.org
@ 2022-05-02 4:38 ` pinskia at gcc dot gnu.org
2022-05-02 5:51 ` jakub at gcc dot gnu.org
2022-05-02 5:53 ` jakub at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-05-02 4:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103612
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=77760
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Looks like this actually might have gotten fixed for GCC 12. See bug #77760
comment #2 for the commit.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libstdc++/103612] get_time %y parsing error for two digits year
2021-12-08 3:01 [Bug libstdc++/103612] New: get_time parsing error for two digits year pyaggi at gmail dot com
` (3 preceding siblings ...)
2022-05-02 4:38 ` [Bug libstdc++/103612] get_time %y " pinskia at gcc dot gnu.org
@ 2022-05-02 5:51 ` jakub at gcc dot gnu.org
2022-05-02 5:53 ` jakub at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-05-02 5:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103612
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
%y and %Y behave differently, %Y is always the full year, 0-9999, up to 4
digits.
%y is if 0-99, up to 2 digits using the POSIX rules 0-68 is 2000 to 2068, 69-99
is 1969 to 1999, but intentionally for backwards compatibility if it is
actually 3 or 4 digits, it is treated as %Y because that is how libstdc++ has
been treating it for years.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libstdc++/103612] get_time %y parsing error for two digits year
2021-12-08 3:01 [Bug libstdc++/103612] New: get_time parsing error for two digits year pyaggi at gmail dot com
` (4 preceding siblings ...)
2022-05-02 5:51 ` jakub at gcc dot gnu.org
@ 2022-05-02 5:53 ` jakub at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-05-02 5:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103612
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Note, the above is GCC 12 behavior, in 11.x and earlier it has been indeed
broken and %y and %C were aliases to %Y.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-05-02 5:53 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-08 3:01 [Bug libstdc++/103612] New: get_time parsing error for two digits year pyaggi at gmail dot com
2021-12-08 3:05 ` [Bug libstdc++/103612] " pinskia at gcc dot gnu.org
2021-12-08 3:45 ` pyaggi at gmail dot com
2022-05-02 4:36 ` pinskia at gcc dot gnu.org
2022-05-02 4:38 ` [Bug libstdc++/103612] get_time %y " pinskia at gcc dot gnu.org
2022-05-02 5:51 ` jakub at gcc dot gnu.org
2022-05-02 5:53 ` jakub at gcc dot gnu.org
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).