================ @@ -1721,11 +1721,13 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) { Diag(Tok.getLocation(), diag::warn_pp_date_time); // MSVC, ICC, GCC, VisualAge C++ extension. The generated string should be // of the form "Ddd Mmm dd hh::mm::ss yyyy", which is returned by asctime. - const char *Result; + const char *Result = "??? ??? ?? ??:??:?? ????"; + char TimeString[64]; if (getPreprocessorOpts().SourceDateEpoch) { time_t TT = *getPreprocessorOpts().SourceDateEpoch; std::tm *TM = std::gmtime(&TT); - Result = asctime(TM); + if (strftime(TimeString, sizeof TimeString, "%a %b %e %T %Y", TM) != 0) ---------------- AaronBallman wrote:
SHOOT, yes, that is expected, same for `%a`. > This is why i suggested the C++ approach here > https://github.com/llvm/llvm-project/pull/99075#issuecomment-2233382915 We can't use that approach because we need to compile in C++17 mode: https://compiler-explorer.com/z/xosc68WMn Okay, so how's this for horrible: ``` bool Failed = false; if (const char *OldLocale = ::setlocale(LC_TIME, "C")) { if (strftime(...)) { } else { Failed = true; } ::setlocale(LC_TIME, OldLocale); } else { Failed = true; } if (Failed) { // Emit question marks instead } ``` https://github.com/llvm/llvm-project/pull/99075 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits