I have achieved weird results with std::mktime on Apple Clang. I have extracted an MCV:
#include <sstream>
#include <iomanip>
#include <iostream>
std::time_t test()
{
std::stringstream stream;
stream << "12:30";
struct tm tm = {};
stream >> std::get_time(&tm, "%H:%M");
std::time_t t = std::mktime(&tm);
return t;
}
int main()
{
std::cout << static_cast<long int>(test()) << std::endl;
return 0;
}
Here I am parsing a string containing a valid time. std::get_time() parses time and saves it to tm object correctly.
std::mktime() always returns -1 on Apple Clang, what indicates an error (but it is impossible to figure out which one exactly). My Clang version:
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin17.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
I have tested this code on Wandbox, it works correctly with GCC since 5.1.0 and with Clang since 3.2 and prints -2209062600.
Looks like an Apple Clang bug to me.