[Bug libstdc++/78714] New: std::get_time does not accept full month name in %b
cubbi at cubbi dot org
gcc-bugzilla@gcc.gnu.org
Wed Dec 7 14:53:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78714
Bug ID: 78714
Summary: std::get_time does not accept full month name in %b
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: cubbi at cubbi dot org
Target Milestone: ---
The standard says time_get calls get_time which follows "ISO/IEC 9945 function
strptime" ([locale.time.get.members]p8.4)
strptime defines the meaning of %b as "The month, using the locale's month
names; either the abbreviated or full name may be specified.":
http://pubs.opengroup.org/onlinepubs/9699919799/functions/strptime.html
however it appears libstdc++ only accepts abbreviated month name:
https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/bits/locale_facets_nonio.tcc#L673-L678
testcase:
#include <iostream>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <time.h>
tm t;
int main()
{
assert(strptime("2011-Feb-18 23:12:34", "%Y-%b-%d %H:%M:%S", &t)); // pass
assert(strptime("2011-February-18 23:12:34", "%Y-%b-%d %H:%M:%S", &t)); //
pass
{
std::istringstream ss("2011-Feb-18 23:12:34");
assert(ss >> std::get_time(&t, "%Y-%b-%d %H:%M:%S")); // pass
}
{
std::istringstream ss("2011-February-18 23:12:34");
assert(ss >> std::get_time(&t, "%Y-%b-%d %H:%M:%S")); // FAIL
}
}
all asserts pass with clang's libc++ and with MSVC 2015
More information about the Gcc-bugs
mailing list