[llvm-bugs] [Bug 36232] New: std::get_time incorrectly parses string produced by std::put_time

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Feb 4 10:04:46 PST 2018


https://bugs.llvm.org/show_bug.cgi?id=36232

            Bug ID: 36232
           Summary: std::get_time incorrectly parses string produced by
                    std::put_time
           Product: libc++
           Version: unspecified
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: dkstrickland2 at gmail.com
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

Created attachment 19810
  --> https://bugs.llvm.org/attachment.cgi?id=19810&action=edit
c++ to reproduce std::get_time problem

std::get_time fails to correctly parse a date/time string produced by
std::put_time using the same format.

See the following output. In the last format used (which is equivalent to the
linux/OSX 'date' command), get_time does not get the year correct, so it
appears as 0 (i.e. 1900). I'm less concerned about the first two cases where
the input/output std::tm structs are not identical as long as the initial and
final string representations are equivalent.

azathoth Clang 12:55:52$ ./GetTimeTest 
Testing format: %F %T
  Result of put_time on tm1: 2008-01-02 12:23:45
  WARN: Struct from get_time, tm2!=tm1. Possible BUG?.
  Result of put_time on tm2: 2008-01-02 12:23:45
  OK: String repr of get_time tm2 == string repr of tm1.
Testing format: %Y-%m-%d %H:%M:%S
  Result of put_time on tm1: 2008-01-02 12:23:45
  WARN: Struct from get_time, tm2!=tm1. Possible BUG?.
  Result of put_time on tm2: 2008-01-02 12:23:45
  OK: String repr of get_time tm2 == string repr of tm1.
Testing format: %a %b %e %T %Z %Y
  Result of put_time on tm1: Wed Jan  2 12:23:45 EST 2008
  WARN: Struct from get_time, tm2!=tm1. Possible BUG?.
  Result of put_time on tm2: Wed Jan  2 12:23:45 EST 1900
  ERROR: String repr of get_time tm2 != string repr of tm1. PROBLEM.

Code to reproduce problem is attached. I'm running this on OSX El Capitan,
using the xcode provided version of clang and libc++:

otool -L GetTimeTest
GetTimeTest:
        /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version
120.1.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
version 1226.10.1)

pkgutil --file-info /usr/lib/libc++.1.dylib 
volume: /
path: /usr/lib/libc++.1.dylib

pkgid: com.apple.pkg.Essentials
pkg-version: 10.11.6.1.1.1502239837
install-time: 1515023711
uid: 0
gid: 0
mode: 755

c++ -v
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180204/45199bfe/attachment.html>


More information about the llvm-bugs mailing list