Special case some duration arithmetic for GCC and PPC because their long double constant folding is broken. Fixes PR#39696.
llvm-svn: 357478
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: 3bf63cf3b366d3a57cf5cbad4112a6abf6c0c3b1
diff --git a/include/thread b/include/thread
index df06ff7..400459a 100644
--- a/include/thread
+++ b/include/thread
@@ -434,7 +434,12 @@
using namespace chrono;
if (__d > duration<_Rep, _Period>::zero())
{
+#if defined(_LIBCPP_COMPILER_GCC) && (__powerpc__ || __POWERPC__)
+ // GCC's long double const folding is incomplete for IBM128 long doubles.
+ _LIBCPP_CONSTEXPR duration<long double> _Max = duration<long double>(ULLONG_MAX/1000000000ULL) ;
+#else
_LIBCPP_CONSTEXPR duration<long double> _Max = nanoseconds::max();
+#endif
nanoseconds __ns;
if (__d < _Max)
{