@@ -1734,7 +1734,7 @@ namespace __format
}
#endif
- if (_M_spec._M_localized)
+ if (_M_spec._M_localized && __builtin_isfinite(__v))
{
__wstr = _M_localize(__str, __expc, __fc.locale());
if (!__wstr.empty())
@@ -248,6 +248,14 @@ test_locale()
s = std::format(cloc, "{:05L}", -1.0); // PR libstdc++/110968
VERIFY( s == "-0001" );
+ // PR libstdc++/114863 grouping applied to nan and inf
+ double inf = std::numeric_limits<double>::infinity();
+ s = std::format(eloc, "{0:Le} {0:Lf} {0:Lg}", -inf);
+ VERIFY( s == "-inf -inf -inf" );
+ double nan = std::numeric_limits<double>::quiet_NaN();
+ s = std::format(eloc, "{0:Le} {0:Lf} {0:Lg}", -nan);
+ VERIFY( s == "-nan -nan -nan" );
+
// Restore
std::locale::global(cloc);
}